From: avtuvy via AccessMonster.com on 29 Mar 2010 09:08 I cretaed a form which is bound to a table and includes a "save" button which calls acCmdSaveRecord. With the way it is now if I change any information in the form the data is saved immedietly into the table. I would like to change it so only when the "save" button is clicked data will be saved. Is there an easy way to do that or it needds to be done with VBA? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201003/1
From: Allen Browne on 29 Mar 2010 11:08 The *only* way to catch the save is to use the BeforeUpdate event of the form. Access fires that event regardless of what triggers the save. In general, this is bad technique. Whatever it is you need to do (validation?), just move it into Form_BeforeUpdate, and let the user save the record however they wish. If you must do it, here's how: 1. Declare a boolean variable in the General Declarations section (top) of the form's module: Private bAllowSave As Boolean 2. Set up the form's BeforeUpdate event procedure to cancel the save unless the button was clicked: Private Sub Form_BeforeUpdate(Cancel As Integer) If bAllowSave Then bAllowSave = False 'put your validation code here. Else Cancel = True MsgBox "Click the button, dummy!" End If End Sub 3. Set up the Click event procedure of your button like this: Private Sub Command1_Click() bAllowSave = True Me.Dirty = False bAllowSave = False End Sub -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "avtuvy via AccessMonster.com" <u58699(a)uwe> wrote in message news:a5bbb2f0f7a8d(a)uwe... > I cretaed a form which is bound to a table and includes a "save" button > which > calls acCmdSaveRecord. With the way it is now if I change any information > in > the form the data is saved immedietly into the table. I would like to > change > it so only when the "save" button is clicked data will be saved. Is there > an > easy way to do that or it needds to be done with VBA? > > -- > Message posted via AccessMonster.com > http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/201003/1 >
|
Pages: 1 Prev: using Control to populate combobox Next: How Do I Chart This in Microsoft Access? |