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
    1. Advertisements

  2. Rod Speed

    Jon Lewis Guest

    Like this:

    Function DoSomething(What As String)
    MsgBox What
    End Function

    Each button's click event:

    '=DoSomething([Screen].[ActiveControl].[Caption])'
    (without the quotes)

    HTH



    "Rod Speed" <> wrote in message
    news:...
    >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 ?
     
    Jon Lewis, Aug 3, 2012
    #2
    1. Advertisements

  3. Rod Speed

    Rod Speed Guest

    Jon Lewis <> wrote

    > Like this:


    > Function DoSomething(What As String)
    > MsgBox What
    > End Function


    > Each button's click event:


    > '=DoSomething([Screen].[ActiveControl].[Caption])'
    > (without the quotes)


    > HTH


    Thanks for that, exactly what I wanted.

    >
    >
    > "Rod Speed" <> wrote in message
    > news:...
    >>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 4, 2012
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. XMan

    Bold Caption in Tab Control

    XMan, Oct 13, 2003, in forum: Access Forms Coding
    Replies:
    1
    Views:
    92
    Allen Browne
    Oct 13, 2003
  2. Marcel K.

    Looping based on control naming convention

    Marcel K., Nov 3, 2003, in forum: Access Forms Coding
    Replies:
    4
    Views:
    99
    Steve Conway
    Nov 4, 2003
  3. rudwan

    Naming Forms In The Code

    rudwan, Feb 9, 2004, in forum: Access Forms Coding
    Replies:
    4
    Views:
    66
    PC Datasheet
    Feb 9, 2004
  4. Jake B

    MSg Box naming

    Jake B, Apr 2, 2004, in forum: Access Forms Coding
    Replies:
    2
    Views:
    63
    Gerald Stanley
    Apr 2, 2004
  5. Yarik Mezheritskiy
    Replies:
    3
    Views:
    328
    Allen Browne
    Nov 5, 2004
  6. Angi

    use control value in form caption

    Angi, Feb 8, 2005, in forum: Access Forms Coding
    Replies:
    6
    Views:
    124
  7. Kurt
    Replies:
    2
    Views:
    79
  8. DJW

    Renaming a control's caption property?

    DJW, Oct 2, 2006, in forum: Access Forms Coding
    Replies:
    2
    Views:
    156
    Granny Spitz via AccessMonster.com
    Oct 2, 2006
Loading...