On Change Event

brianjessup

Registered User.
Local time
Yesterday, 22:53
Joined
May 25, 2003
Messages
36
I have a bit of a twichy on Change event problem. When I first load the form up and change a txtbox, the on change event seems to work fine (more on that later), doing exactly what it is supposed to do, which is loop through a series of records comparing the value I entered to the recordset to find matches. However, when I change the value in the txtbox, say from '2' to '1', at first it acts like the '2' is still present and will return the first record with a '2', but then it settles down, and acts like a '1' for the remainder of the search. If I type in the '1' again I finally get everything the way I want it. It's almost as if the on change event grabs the '2' before I can change it.

Also, I had to insert an if statement testing the IsNull condition on the txtbox, or again when the form is first opened and there is nothing in the box, the first search will look for Null. If I use the AfterUpdate event, everything works smoothly, so I think it must be something about the txtbox setup or how I'm using the change event. I'd really rather use the on change event, so if anyone has any thoughts I'd be appreciative.

Thanks!
 
The OnChange event is inappropriate for this purpose. The event fires each time a character is entered in the the textbox. That's why it is twichy. Use the BeforeUpdate event if you want to cancel the update if the record is not found. Or, use a combobox to select the appropriate record rather than typing in the value.
 

Users who are viewing this thread

Back
Top Bottom