BeforeUpdate disappears

taw

Registered User.
Local time
Today, 08:17
Joined
Nov 21, 2002
Messages
34
I am making some changes to an Access97 database that I didn't build. It also uses a lot of macros, of which I know little. On one particular form, I want to check and make sure a date was entered before saving the record. I have built the code in the Form_BeforeUpdate sub. I clicked on the before update event in the property manager to do this. The problem is that the code is there, in the correct place, but is not firing. Every time I check the form properties, the Before Update event is blank. If I click again on the build code, it takes me to the right spot, but I can save and return to the form and it is not showing anything under Before Update.

There are macros running in After Insert, After Update, On Open, and On Got Focus for the form. When I first started working on this db, I copied to a new file and imported everything, so I don't think it's a corruption issue.

Anyone know why this would happen? I did notice that the form is using a query on two tables, would this make a difference?

Thanks,
Tom
 
I would agree that the Form_BeforeUpdate event should be the right place to test for proper completion.

I have no idea why an event would be doing what you describe. AC97 is, to be blunt, not that smart.

However, macros can be the entry points for "smart" code. See if any of the involved macros includes a RunCode action. (That means the macro calls a VBA function.) That's where you start looking if you think the macro is funky in some way.

Do a "Help" search on topic "Events" - even for AC97 help files, you have a roadmap for form events. You would find that there are several events in a sequence. If the form's BeforeUpdate event isn't firing then see what precedes that event.

The other issue is, does the data underneath form actually get updated? If not, then your observation is correct.

Now, as to why a form gets updated... it gets DIRTY. (No, not kidding. Forms have a property called "DIRTY".) It is dirty when at least one control's value mismatches the value that was loaded when the form became current. Each control has an .OldValue property to support knowing this. The controls never get dirty - but the form surely does. If something reverts all records to the .OldValue for all fields, then it isn't dirty and there is nothing to update.

See if there is an .Undo action anywhere because that would have the effect of undoing any changes made on the form. Certainly worth considering.
 
Thanks Doc Man,

Your suggestions give me some places to start looking. As a temporary fix, I just made the control in question required. I just wanted a little more graceful message than the standard one you get with that.

When I find the culprit, I'll post back.

Thanks again,

Tom
 
Does the forms property sheet say [Event Procedure] in the Before Update?
 
Rich,

Actually that is what the original problem was - no matter what I did, when I opened the form, it would remove the [Event Procedure] from Before Update in the property sheet. I even tried building some code for another procedure and that one worked.

Of course I didn't try closing everything and then reopening the form. I just did that and it works fine. Ugh!

Thanks for help,

Tom
 

Users who are viewing this thread

Back
Top Bottom