AFTERUPDATE Event

W

Wayne

I created a simple form to add / change data base records, one record at a
time. I use a combo box with a combo.afterupdate event that triggers a VB
proc to position the form to the correct record. This technique works OK.

I now want to use the form.beforeupdate event in order to (1) determine that
one or more controls in the form were updated and (2) add some additional
data to the current record before it is finally updated.

The problem that I cannot seem to solve is that the form.beforeupdate event
is triggered by the combo.beforeupdate event. I need somehow disable the
combo.beforeupdate event or have the form.beforeupdate event proc know which
event it is trying to process.

Any suggestions out there!
 
G

Graham Mandeno

Hi Wayne

It is not the combo's AfterUpdate event per se that is causing
Form_BeforeUpdate to fire, but rather that the combo's AfterUpdate event
procedure is navigating to a new record, which forces an attempted save of
the current record.

I can see why it could be disconcerting, because any message about saving
the old record would not appear until *after* the user had selected the new
one to move to.

I suggest you use the combo's GotFocus event to check if the current record
is dirty and, if so, attempt to save it. If that save fails for some
reason, then set focus back to some other control.
 
W

Wayne

OK...got that!

Let me ask one more question...as I change records using the
combo.afterupdate proc, I understood that the form.beforeupdate proc would
trigger only if there was a change in any of the controls on the form. Does
that mean since I *changed* the combo box, I triggered the beforeupdate?

Thanks in advance for your response. I'm a novice and learn by trial and
error, so this is very helpful.

Wayne M.


Graham Mandeno said:
Hi Wayne

It is not the combo's AfterUpdate event per se that is causing
Form_BeforeUpdate to fire, but rather that the combo's AfterUpdate event
procedure is navigating to a new record, which forces an attempted save of
the current record.

I can see why it could be disconcerting, because any message about saving
the old record would not appear until *after* the user had selected the new
one to move to.

I suggest you use the combo's GotFocus event to check if the current record
is dirty and, if so, attempt to save it. If that save fails for some
reason, then set focus back to some other control.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Wayne said:
I created a simple form to add / change data base records, one record at a
time. I use a combo box with a combo.afterupdate event that triggers a VB
proc to position the form to the correct record. This technique works OK.

I now want to use the form.beforeupdate event in order to (1) determine
that
one or more controls in the form were updated and (2) add some additional
data to the current record before it is finally updated.

The problem that I cannot seem to solve is that the form.beforeupdate
event
is triggered by the combo.beforeupdate event. I need somehow disable the
combo.beforeupdate event or have the form.beforeupdate event proc know
which
event it is trying to process.

Any suggestions out there!
 
G

Graham Mandeno

Hi Wayne

No, the combo box is (or should be!) an unbound control, so changing its
value will not make the form record dirty.

Remember that changing the value in the combo is not forcing the save - it
is the navigation to a new record that does it. The fact that the
navigation is *caused* by the change in the combo is beside the point.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


Wayne said:
OK...got that!

Let me ask one more question...as I change records using the
combo.afterupdate proc, I understood that the form.beforeupdate proc would
trigger only if there was a change in any of the controls on the form.
Does
that mean since I *changed* the combo box, I triggered the beforeupdate?

Thanks in advance for your response. I'm a novice and learn by trial and
error, so this is very helpful.

Wayne M.


Graham Mandeno said:
Hi Wayne

It is not the combo's AfterUpdate event per se that is causing
Form_BeforeUpdate to fire, but rather that the combo's AfterUpdate event
procedure is navigating to a new record, which forces an attempted save
of
the current record.

I can see why it could be disconcerting, because any message about saving
the old record would not appear until *after* the user had selected the
new
one to move to.

I suggest you use the combo's GotFocus event to check if the current
record
is dirty and, if so, attempt to save it. If that save fails for some
reason, then set focus back to some other control.

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Wayne said:
I created a simple form to add / change data base records, one record at
a
time. I use a combo box with a combo.afterupdate event that triggers a
VB
proc to position the form to the correct record. This technique works
OK.

I now want to use the form.beforeupdate event in order to (1) determine
that
one or more controls in the form were updated and (2) add some
additional
data to the current record before it is finally updated.

The problem that I cannot seem to solve is that the form.beforeupdate
event
is triggered by the combo.beforeupdate event. I need somehow disable
the
combo.beforeupdate event or have the form.beforeupdate event proc know
which
event it is trying to process.

Any suggestions out there!
 

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