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!
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
--
PS: If this is a satisfying answer to your question and you're logged in via
the Microsoft site, please click Yes to "Did this post answer the question?".
Thanks.
> 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
[quoted text clipped - 6 lines]
>
> Thanks in advance!