Getting a caption without naming the control

R

Rod Speed

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 ?
 
J

Jon Lewis

Like this:

Function DoSomething(What As String)
MsgBox What
End Function

Each button's click event:

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

HTH
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top