Event Question

G

Guest

The code below was placed in an unbound text box to select the order number
(not record number) to view and it works great. This code was entered in the
After_Update event:

If Me.Dirty Then 'Save first
Me.Dirty = False
End If
If IsNull(Me.OrderFind) Then 'Show all
Me.FilterOn = False
Else
Me.Filter = "[order] Like """ & Me.OrderFind & "*"""
Me.FilterOn = True
End If

Then I got the bright idea of setting up a button to add one to the number
in the text box and then pass focus to the box. I could repeat the use of the
button as needed to get to the order number I wanted. However, it appears
that since the text box was changed by another control, the update procedure
is bypassed and the after_update event is not executed. The code in the on
click event of the button is as follows:

If Me.Dirty Then 'Save first
Me.Dirty = False
End If
Me.OrderFind = Me.OrderFind + 1
Me.OrderFind.SetFocus


Is there some way to correct this problem or do I need to move the code to a
different event?
 
B

Brendan Reynolds

The AfterUpdate (and BeforeUpdate) events are not fired when a control's
value is changed programmatically. You could add your code from the
AfterUpdate event procedure to the Click event of the command button. If
there is code that you want to run regardless of whether the value was
changed manually or programmatically, you can move that code to a
subprocedure, then you can call the subprocedure from both the AfterUpdate
event procedure and from the Click event procedure of your command button.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

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