S
SandyR
I have a form which I open, then try to move to the next record without
making any changes. I have the form_before_update event set up to not allow
the user to leave a changed record without saving it. The before_update
event is firing even though no changes have been made. Can anyone tell me
why? Here are the subs that trigger on the way:
Private Sub Form_Load()
On Error GoTo Form_Load_Error
'vSaveFlag is a public boolean used to prevent involuntary record saving
vSaveFlag = False
Me.AllowEdits = False
Me.NavigationButtons = True
Me.btnedit.Enabled = True
Me.btnSave.Enabled = Me.NewRecord
Me.btnCancel.Enabled = Me.NewRecord
' set focus to field to find record on
Me.LNAME.SetFocus
Me.btnFind.Enabled = Not Me.NewRecord
Me.btnDelete.Enabled = Not Me.NewRecord
'txtelection = [Forms]![frmElection]![ELNO]
On Error GoTo 0
Exit Sub
Form_Load_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Load of VBA Document Form_election with buttons"
End Sub
Private Sub Form_Current()
On Error GoTo Form_Current_Error
vSaveFlag = False
On Error GoTo 0
Exit Sub
Form_Current_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmballots"
End Sub
rivate Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Error
If Me.Dirty Then
If vSaveFlag = False Then
MsgBox ("Please save the record or cancel")
Cancel = True
End If
End If
On Error GoTo 0
Exit Sub
Form_BeforeUpdate_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_BeforeUpdate of VBA Document Form_frmballots"
End Sub
making any changes. I have the form_before_update event set up to not allow
the user to leave a changed record without saving it. The before_update
event is firing even though no changes have been made. Can anyone tell me
why? Here are the subs that trigger on the way:
Private Sub Form_Load()
On Error GoTo Form_Load_Error
'vSaveFlag is a public boolean used to prevent involuntary record saving
vSaveFlag = False
Me.AllowEdits = False
Me.NavigationButtons = True
Me.btnedit.Enabled = True
Me.btnSave.Enabled = Me.NewRecord
Me.btnCancel.Enabled = Me.NewRecord
' set focus to field to find record on
Me.LNAME.SetFocus
Me.btnFind.Enabled = Not Me.NewRecord
Me.btnDelete.Enabled = Not Me.NewRecord
'txtelection = [Forms]![frmElection]![ELNO]
On Error GoTo 0
Exit Sub
Form_Load_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Load of VBA Document Form_election with buttons"
End Sub
Private Sub Form_Current()
On Error GoTo Form_Current_Error
vSaveFlag = False
On Error GoTo 0
Exit Sub
Form_Current_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_Current of VBA Document Form_frmballots"
End Sub
rivate Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_Error
If Me.Dirty Then
If vSaveFlag = False Then
MsgBox ("Please save the record or cancel")
Cancel = True
End If
End If
On Error GoTo 0
Exit Sub
Form_BeforeUpdate_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
Form_BeforeUpdate of VBA Document Form_frmballots"
End Sub