Here is the code I'm using:
Private Sub Save_Click(Cancel As Integer)
On Error GoTo Err_Save_Click
DoCmd.SetWarnings (Not dataOK)
DoCmd.GoToRecord , , acNewRec
Exit_Save_Click:
Exit Sub
Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click
DoCmd.SetWarnings (Not dataOK)
DoCmd.Close
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
DoCmd.SetWarnings (Not dataOK)
End Sub
Private Function dataOK() As Boolean
'Assume success
dataOK = True
'Now test for emptiness
If Me.ContactFirstName = "" Then
MsgBox "You have not entered a First Name.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.ContactLastName = "" Then
MsgBox "You have not entered a Last Name.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Previous_Address = "" Then
MsgBox "You have not entered a Previous Address.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Text26 = "" Then
MsgBox "You have not entered a City.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Text28 = "" Then
MsgBox "You have not entered a State/Province.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Text30 = "" Then
MsgBox "You have not entered a ZIP Code.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.DOB = "" Then
MsgBox "You have not entered a Date of Birth.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.SSN = "" Then
MsgBox "You have not entered a Social Security Number.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.DL__ = "" Then
MsgBox "You have not entered a Drivers License Number.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Text42 = "" Then
MsgBox "You have not entered a Building Number.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Text44 = "" Then
MsgBox "You have not entered a Unit Number.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Lease_Start_Date = "" Then
MsgBox "You have not entered a Lease Start Date.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Lease_End_Date = "" Then
MsgBox "You have not entered a Lease End Date.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.Deposit = "" Then
MsgBox "You have not entered a Security Deposit amount.", vbOKOnly + vbExclamation
dataOK = False
ElseIf Me.MonthlyRent = "" Then
MsgBox "You have not entered a Monthly Rent amount.", vbOKOnly + vbExclamation
dataOK = False
dataOK = False
End If
End Function
Now, as you can see, I don't have the above mentioned section in the function. And when I click on my save or close buttons, I get this error: The Expression On Click you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.
Any ideas on what I'm doing wrong?
Thanks!
David Somers