Getting same error and I'm at a complete loss.
Was working up until I got cute and decided to use more descriptive names for the command buttons.
Got the error msg immediately after that and I cant make it go away.
Tried renaming the buttons, but to no avail.
Please HELPPPP!!!
CODE:
Option Compare Database
Public txtClicked As String
Private Sub ExitBtn_Click(Cancel As Integer)
Dim saveAns As Integer
saveAns = MsgBox("Exit without saving?", vbYesNo)
'If 'Save' Button IS Clicked...
If txtClicked = "Yes" Then
If IsNull(Me.BLOCK) Or IsNull(Me.LOT) Or IsNull(Me.ZONE) Or IsNull(Me.BLDG_NUM) Or IsNull(Me.STREET) Or IsNull(Me.ATERY) Or IsNull(Me.ADDED_BY) Or IsNull(Me.OIL_TYPE) Then
Cancel = True
MsgBox "Some required fields have not been completed."
End If
Else
'If 'Save' Button IS NOT Clicked...
If saveAns = vbYes Then
Me.Undo
DoCmd.Close acForm, acSaveNo
DoCmd.OpenForm "SWITCHBOARD"
Else
Cancel = True
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim saveAns As Integer
saveAns = MsgBox("Exit without saving?", vbYesNo)
'If <<'Save' Button IS Clicked>> Then
If txtClicked = "Yes" Then
If IsNull(Me.BLOCK) Or IsNull(Me.LOT) Or IsNull(Me.ZONE) Or IsNull(Me.BLDG_NUM) Or IsNull(Me.STREET) Or IsNull(Me.ATERY) Or IsNull(Me.ADDED_BY) Or IsNull(Me.OIL_TYPE) Then
Cancel = True
MsgBox "Some required fields have not been completed."
End If
Else
'If <<Macro-based 'Save' Button IS NOT Clicked>> Then
If saveAns = vbYes Then
Me.Undo
DoCmd.Close acForm, acSaveNo
DoCmd.OpenForm "SWITCHBOARD"
Else
Cancel = True
End If
End If
End Sub
Private Sub SaveBtn_Click(Cancel As Integer)
If IsNull(Me.BLOCK) Or IsNull(Me.LOT) Or IsNull(Me.ZONE) Or IsNull(Me.BLDG_NUM) Or IsNull(Me.STREET) Or IsNull(Me.ATERY) Or IsNull(Me.ADDED_BY) Or IsNull(Me.OIL_TYPE) Then
Cancel = True
MsgBox "Some required fields have not been completed."
Else
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Record Saved"
End If
End Sub