capturing checkbox result

A

abbarition

I have macros running on enter and exit of my form fields. I capture the
result of the form field during both macros and am comparing the two values
to see if the field was changed. However, if I click into a checkbox, it
changes the result of the checkbox, runs tne exit macro for the previous
field, and then runs the enter macro for the checkbox. So when it runs the
enter macro, it is capturing the changed result. Is there a way around this?
Or should I always capture the opposite result on entering a checkbox (false
for true and true for false)?

Thanks in advance!
 
C

Cooz

Hi abbarition,

No, you should definitely _not_ capture the opposite result since a user may
use the tab key to navigate between form fields. This way the result does not
change.

I find that when I use the macros below, the exit macro of the previous
field is run, the result of the next field is (not - if the tab key is used)
changed, and the enter macro of the next field is run. Which is the sequence
you want.

Now that I think of it... you state: "if I click into a checkbox, it changes
the result of the checkbox" - in which you click, I presume. But then, that
should be ok, shouldn't it? You for example click to clear a checkbox, and
the enter macro captures the "clear". If you mean that your macros change the
result of the previous checkbox, you are right - that is not what you want.

Anyway, here are mine:

Sub EnterMacro()
MsgBox Selection.FormFields(1).Name & " " & _
Selection.FormFields(1).Result, 0, "Enter"
End Sub
Sub ExitMacro()
MsgBox Selection.FormFields(1).Name & " " & _
Selection.FormFields(1).Result, 0, "Exit"
End Sub

Good luck,
Cooz
 

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