I need to write a macro which is called when a form
checkbox is checked (or unchecked) and determines what the
name of the checkbox is that triggered the macro.

For example, if the user checks Checkbox1, the macro needs
to be able to load that name into a variable.

Is anyone aware of how I could do this, or more
importantly does anyone have a code example that would
work for this?

-Thanks much,
Jon

Retrieve caller by Lerxst

Lerxst
Wed Jul 07 16:18:26 CDT 2004

Use the checkbox's change event.


>-----Original Message-----
>I need to write a macro which is called when a form
>checkbox is checked (or unchecked) and determines what
the
>name of the checkbox is that triggered the macro.
>
>For example, if the user checks Checkbox1, the macro
needs
>to be able to load that name into a variable.
>
>Is anyone aware of how I could do this, or more
>importantly does anyone have a code example that would
>work for this?
>
>-Thanks much,
>Jon
>.
>

Retrieve caller by anonymous

anonymous
Thu Jul 08 07:13:10 CDT 2004

I don't understand. I will admit I'm not a full-time
programmer and just write a little when needed around the
office. How could a change event figure out which checkbox
triggered the macro and thus capture it's name? The macro
is triggered 'upon entry' in it's properties which starts
the macro. I need to be able to get that checkbox name
which caused the macro to run.

-thanks, Jon


>-----Original Message-----
>Use the checkbox's change event.
>
>
>>-----Original Message-----
>>I need to write a macro which is called when a form
>>checkbox is checked (or unchecked) and determines what
>the
>>name of the checkbox is that triggered the macro.
>>
>>For example, if the user checks Checkbox1, the macro
>needs
>>to be able to load that name into a variable.
>>
>>Is anyone aware of how I could do this, or more
>>importantly does anyone have a code example that would
>>work for this?
>>
>>-Thanks much,
>>Jon
>>.
>>
>.
>

Re: Retrieve caller by Jean-Guy

Jean-Guy
Thu Jul 08 07:45:48 CDT 2004

Bonjour,

Dans son message, < anonymous@discussions.microsoft.com > écrivait :
In this message, < anonymous@discussions.microsoft.com > wrote:

|| I don't understand. I will admit I'm not a full-time
|| programmer and just write a little when needed around the
|| office. How could a change event figure out which checkbox
|| triggered the macro and thus capture it's name? The macro
|| is triggered 'upon entry' in it's properties which starts
|| the macro. I need to be able to get that checkbox name
|| which caused the macro to run.
||
|| -thanks, Jon

Try the following code to get you going.
By the way, if you want to do something based on the checkbox state as set
by the user, it would be better to use the On Exit property so as to get the
information based on what the user did in the checkbox, not how it is before
the user does anything, which is what you would get with the On Entry call.

'_______________________________________
Sub GetName()

Dim CheckName As String

With Selection
CheckName = .FormFields(1).Name
MsgBox CheckName
End With

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org