Table modifying before pressing the Save Changes button

  • Thread starter Paul via AccessMonster.com
  • Start date
P

Paul via AccessMonster.com

I have given as Select statement in my form's record sourse.
(Me.RecordSource = " Select * from My_Table"). And I have a Save Changes
button with code "DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,
, acMenuVer70". If I am changing any values in the form, it is changing
immediately in the table. I want the changes in the table only after
clicking the Save Changes button, If I didn't press the Save changes
button, The values should not be modified. Please help me.
 
A

Allen Browne

Paul, there are so many ways the save can happen, e.g. cycle out of the last
contol on the form, or backwads from the first, move to another record,
close the form, close Access, apply a filter, change the sort order, press
Shift+Enter, choose Save Record from the Records menu, etc, etc.

The ONLY way you can catch them all is to cancel the BeforeUpdate event of
the *form*. If you want to force the save through your command button only,
then you need a form-level boolean variable that you set to True in the
button's Click event before your save-record code, and reset to False again
in Form_BeforeUpdate. If it is not True, then cancel the Form_BeforeUpdate
event to prevent the save.

In 99.9% of cases, this is a waste of effort. It is far more efficient (and
far less frustrating for the user), if you move whatever code you want to
happen out of your button's Click event, and into Form_BeforeUpdate.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 

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