Need an Event, Code Doesn't Cause One

G

Guest

Have a date control that can be updated two ways: either by typing in (or
changing or deleting) a date, or by clicking a command button that runs a sub
that opens a calendar dialog, then puts the selected date into the control.
In either case, I then want to evaluate the contents of the control and set a
second control to either "Yes" or "No."

AfterUpdate works just fine for the first scenario, but when I use the
calendar dialog it doesn't appear to kick off any event that I've been able
to identify and tie my evaluation code to. Besides AfterUpdate, have tried
OnExit, LostFocus, OnCurrent (for the form), and everything else I can think
of. Any suggestions?
 
M

Marshall Barton

LarryP said:
Have a date control that can be updated two ways: either by typing in (or
changing or deleting) a date, or by clicking a command button that runs a sub
that opens a calendar dialog, then puts the selected date into the control.
In either case, I then want to evaluate the contents of the control and set a
second control to either "Yes" or "No."

AfterUpdate works just fine for the first scenario, but when I use the
calendar dialog it doesn't appear to kick off any event that I've been able
to identify and tie my evaluation code to. Besides AfterUpdate, have tried
OnExit, LostFocus, OnCurrent (for the form), and everything else I can think
of. Any suggestions?


The Update events are not supposed to fire when you set a
value in code. However, it's simple enough to call the
AfterUupdate event procedure from the procedure that sets
the value. E.g.

Me.txtDate = something
Me.txtDate_AfterUpdate
 
B

Bob Hairgrove

The Update events are not supposed to fire when you set a
value in code. However, it's simple enough to call the
AfterUupdate event procedure from the procedure that sets
the value. E.g.

Me.txtDate = something
Me.txtDate_AfterUpdate

Since the dialog is setting the value in the main form, the OP will
have to declare the AfterUpdate event procedure "Public" in order to
call it from code in the dialog (e.g., right after setting the
control's value).
 
G

Guest

Thanks, Marshall. For some reason I have a mental block about calling event
procedures just like any other sub! I just added that call right after my
code returns from the dialog procedure, and it worked perfectly.
 

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