hello,
I am using the following code to ensure that a new record is not created without the user intending to.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'If the form data has changed a message is shown asking if
'the changes should be saved. If the answer is no then
'the changes are undone
On Error GoTo BeforeUpdate_Error
If Me.Dirty Then
'if record has been changed the dirty property
' is set to true Display message to save the record
If MsgBox("The record has changed - do you want to save it?", _
vbYesNo + vbQuestion, "Save Changes") = vbNo Then
Me.Undo
End If
End If
BeforeUpdate_Exit:
Exit Sub
BeforeUpdate_Error:
MsgBox Err.Description
Resume BeforeUpdate_Exit
End Sub
However, this code is preventing the operation of my "command326" (a run query based on the current field contents button) and "FindRecord" buttons.
My ultimate goal is to be able to ensure that records are not created inadvertantly while still allowing for the form fields to also be used to search the database.
Any help would be greatly appreciated.