开发者

Intercepting automatic save in Microsoft Access

开发者 https://www.devze.com 2023-03-29 22:25 出处:网络
I have an MS-Access form with 3 levels of nested forms within it.The second form has two text boxes -- first name and last name.For some strange reason, as soon as the user begins to type in the first

I have an MS-Access form with 3 levels of nested forms within it. The second form has two text boxes -- first name and last name. For some strange reason, as soon as the user begins to type in the first name, the form attempts to trigger a Save.

How can I figure out who/what/where the save is getting triggered?

I put in a开发者_开发知识库 Form_BeforeInsert handler and I can intercept there, but the call stack doesn't indicate from where the event was tiggered.

Any ideas?


When you switch focus from a control on the parent form to a control on a subform, that switch of focus triggers a save of the parent form's current record if any of its bound controls contain unsaved values. I don't think there is any way to prevent or defer that behavior. You either have to allow the record save or discard the changes. You can intercept the form Before Update event to ask the user whether to save or discard, as @woliveirajr suggested. And you can do the same thing for the Before Insert event.


from http://help.lockergnome.com/office2/Disable-AutoSave-MS-Access--ftopict149090.html

By "Autosave", do you mean the record being saved when you change focus to another record? If so, then there is no built-in way to "turn it off". However, it's easy enough to put some code in the form's BeforeUpdate event:

If MsgBox("Do you want to save changes?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If 

And perhaps you don't want to ask the user about saving it, so the Me.Undo line will do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消