Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop Access automatically saving BEFORE tab's OnChange event?

Status
Not open for further replies.

tpolony

Programmer
Aug 9, 2003
17
US
I wrote an app (with bound data fields) where if a user changed to a different tab on the form, the tab's OnChange event checks for Me.Dirty to prompt user to save first if needed. Worked great.

I'm trying to do the same thing with a new app, but NOW Access is executing an automatic save BEFORE the tab's OnChange event occurs (not happening with the other app). By the time I check Me.Dirty on the tab's OnChange event, it's no longer dirty, so my test always fails.

Any ideas why this works just fine in one place, but not in the other? Is there some setting on my form that needs to be changed? I really want to turn off this automatic save, it's a nuisance.
 
If the new app has a subform on one of the tabbed pages, Access will automatically save the parent form record before shifting focus to the subform. Then, when you set the focus back to the main form by clicking a tab, the parent record will already have been saved. If you don't want the parent record save to happen, you'll need to copy all of the changed parent fields into temporary variables, and use DoCmd.Undo the reset the parent record before allowing focus to shift to the subform. Later on in your parent form processing when you really want to save the record, you'll need to copy the temporary variables back to the bound fields and save the record.
 
Thanks for the tip. I checked the old app and it also has a subform on the 2nd tab, like the new app. But there is a difference in that the new app sets the subform record source only upon clicking the tab, whereas the old one's record source is hard-coded and loads when the parent form initially loads. I'll see if that makes any difference.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top