Getting a caption without naming the control

Discussion in 'Access Forms Coding' started by Rod Speed, Aug 2, 2012.

  1. Rod Speed

    Rod Speed Guest

    I have a form with a considerable number of buttons
    which each set a timer with a variable amount of time.

    Obviously each button is labelled with the time to be set.

    I want to have general purpose code on the click event
    which uses the value that is specified in the caption.

    But I don't want to have to name the control, I want
    to just use a generic reference to the caption so the
    same code can be used when each button is clicked.

    How do I reference the caption in the .Caption form ?
    Rod Speed, Aug 2, 2012
    1. Advertisements

  2. Rod Speed

    Jon Lewis Guest

    Like this:

    Function DoSomething(What As String)
    MsgBox What
    End Function

    Each button's click event:

    (without the quotes)

    Jon Lewis, Aug 3, 2012
    1. Advertisements

  3. Rod Speed

    Rod Speed Guest

    Thanks for that, exactly what I wanted.
    Rod Speed, Aug 4, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.