Preventing Auto-Update of Tables

N

nazir.atif

How do I prevent forms from updating tables automatically when closed?
I want to update the tables only when I press the 'save' button I've
made.
 
J

Jeff Boyce

One approach would be to add code to your <Save> button that sets a
(boolean) flag. Then, in the form's BeforeUpdate event, add code that tests
for the flag. Undo (any) changes if the flag isn't set.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Are you asking me to write the code? What have you already done?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
D

Dave E.

Here's the way I do it: Make a clone of the table (i.e., copy "tblNames" to
"tblTempNames". Then bind your form to the temp table and let the user play
around with it until he/she clicks the save button. Behind that button is
code that runs an append action query to add the temp record to the master
table.
 
N

nazir.atif

It's really independent of what I've done, isn't it? I just want to
prevent the auto-save-on-close "feature" of MS Access, otherwise I just
may have to resort to writing the queries manually instead of joining
tables and using a ready-made query. All I've done (manually) is:

Private Sub Save_New_Record_Click()
On Error GoTo Err_Save_New_Record_Click

ExpCode.SetFocus

If ExpCode.Text <> 0 Then

ExpDate.SetFocus
If ExpDate.Text <> "" Then
Through.SetFocus
If Through.Text <> "" Then


DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70
MsgBox "Form Saved!"
DoCmd.GoToRecord , , acNewRec

ExpCode.SetFocus

Else
MsgBox "No Payment Method Chosen"
End If

Else

MsgBox "Enter Proper Date: MM/DD/YYYY"

End If
End If


Exit_Save_New_Record_Click:
Exit Sub

Err_Save_New_Record_Click:
MsgBox Err.Description
Resume Exit_Save_New_Record_Click

End Sub
 
J

Jeff Boyce

I don't know of a way to "prevent" the automatic feature. The suggestions I
offered work more to cancel the saving unless the "flag" is set.

One way to think about it is to tell Access "don't save unless I tell you
it's OK" -- you'd do this in the BeforeUpdate event of the form. The way
you "tell" Access it's OK is by setting a boolean "flag" to "True" -- this
you'd do in the <Save> button code.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Top