How to override the default "Save"?

N

new.microsoft.com

Access is defaulted to save any change updated to records, however, I want
to write a VBA which user must click the "Save" button in order to save or
update the records, if user did not click the "Save" button, the new change
won't update to the Database. How can I do that?
 
K

Ken Snell

With great difficulty.....and not with macros.

It's not often that it's necessary to "override" ACCESS' built-in save
feature.

To do what you want, you'll need to build your forms using temporary tables
into which the data are to be edited (you must populate these tables with
the current, real data, and then you must copy the data into your real
tables when you want to "save" the data -- if you want to show both the
current and edited data to the user, you'll need twice as many fields: one
for current data, one for edited data). This is a lot of work, and requires
VBA code in most cases.

Are you completely sure that you need to do this?
 
S

Steve Schapel

New,

One idea is to put a Yes/No field in the table, lets say it is called
ToSave, with Default Value set to No. If you are using a macro, use a
SetValue action as the first action in the macro on the Save button,
to set the value of the ToSave field to Yes. Then, in the
BeforeUpdate event of the form, put a macro with the Condition:
[ToSave]=0
.... and the actions:
CancelEvent
RunCommand, Undo

The equivalent can also be done in a VBA procedure.

- Steve Schapel, Microsoft Access MVP
 
K

Ken Snell

Good design idea, Steve. Thanks!

--
Ken Snell
<MS ACCESS MVP>

Steve Schapel said:
New,

One idea is to put a Yes/No field in the table, lets say it is called
ToSave, with Default Value set to No. If you are using a macro, use a
SetValue action as the first action in the macro on the Save button,
to set the value of the ToSave field to Yes. Then, in the
BeforeUpdate event of the form, put a macro with the Condition:
[ToSave]=0
... and the actions:
CancelEvent
RunCommand, Undo

The equivalent can also be done in a VBA procedure.

- Steve Schapel, Microsoft Access MVP


Access is defaulted to save any change updated to records, however, I want
to write a VBA which user must click the "Save" button in order to save or
update the records, if user did not click the "Save" button, the new change
won't update to the Database. How can I do that?
 

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