Event won't fire

  • Thread starter Thread starter UpRider
  • Start date Start date
U

UpRider

I have a bound text box that I update with code. Even though the field is
updated properly, the before_update event does not fire. When I update the
same field via keyboard, it does fire. I tried a docmd.gotocontrol before
the code update, but it didn't help. Any insight into what's going on here?
Thanks, Barto.
 
I have a bound text box that I update with code. Even though the field is
updated properly, the before_update event does not fire. When I update the
same field via keyboard, it does fire. I tried a docmd.gotocontrol before
the code update, but it didn't help. Any insight into what's going on here?
Thanks, Barto.
No, code will not trigger the Before or After Update on a control.
However, that shouldn't be too much of a problem since you know when
it is being updated by the code.

- Jim
 
This is working as advertised - directly from the help file:

Changing data in a control by using Visual Basic or a macro containing the
SetValue action doesn't trigger these events for the control. However, if
you then move to another record or save the record, the form's BeforeUpdate
event does occur.

However, if your code is updating the control you can execute whatever code
you need after the code that updates the textbox. You can also catch any
validation problems in the BeforeUpdate event of the form.
 
Thanks, Sandra and Jim. Looks like the solution is a bit more code on my
part. No problem that.

UpRider

Sandra Daigle said:
This is working as advertised - directly from the help file:

Changing data in a control by using Visual Basic or a macro containing the
SetValue action doesn't trigger these events for the control. However, if
you then move to another record or save the record, the form's BeforeUpdate
event does occur.

However, if your code is updating the control you can execute whatever code
you need after the code that updates the textbox. You can also catch any
validation problems in the BeforeUpdate event of the form.
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have a bound text box that I update with code. Even though the
field is updated properly, the before_update event does not fire.
When I update the same field via keyboard, it does fire. I tried a
docmd.gotocontrol before the code update, but it didn't help. Any
insight into what's going on here? Thanks, Barto.
 
I have a bound text box that I update with code. Even though the field is
updated properly, the before_update event does not fire. When I update the
same field via keyboard, it does fire. I tried a docmd.gotocontrol before
the code update, but it didn't help. Any insight into what's going on here?
Thanks, Barto.

This is in accord with the documentation. Control events do NOT fire
when the control is updated in code.

Since you're in code anyway, you can either perform the desired action
in your own routine, or explicitly call the routine:

Call Controlname_BeforeUpdate()
 
Back
Top