Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click
Dim rst As ADODB.Recordset
Dim strSQL As String
strSQL = "[MemberNumber] = " & Me.MemberNumber
'Duplicate Member?
'instantiate a recordset for the Member table
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "Select * from tblMember"
'Attempt to find this member
.Find strSQL
End With
If Not rst.EOF Then
MsgBox Me.MemberNumber & " Already a member! Try again"
Me.MemberNumber.SetFocus
Exit Sub
End If
Set rst = Nothing
'Check if null or Zero
Dim response As Integer
If Me.MemberNumber = "" Or Me.MemberNumber = 0 Then
response = MsgBox("Invalid MemberNumber! Click OK exit, Cancel to try again!", vbOKCancel)
If response <> vbOK Then
Me.MemberNumber.SetFocus
Exit Sub
End If
End If
'Check if Surname has been input
If IsNull(Surname) Or Me.Surname = "" Then
MsgBox "Surname not entered! "
Me.Surname.SetFocus
Exit Sub
End If
'Check if Forenames has been input
If IsNull(Forenames) Or Me.Forenames = "" Then
MsgBox "Forenames not entered! "
Me.Forenames.SetFocus
Exit Sub
End If
'Check if Title has been input
If IsNull(Title) Or Me.Title = "" Then
MsgBox "Title not entered! "
Me.Title.SetFocus
Exit Sub
End If
'Check if DoB has been input
If IsNull(DoB) Or Me.DoB = "" Or Me.DoB = 0 Then
MsgBox "Date of Birth not entered! "
Me.DoB.SetFocus
Exit Sub
End If
'Check if Phone Number have been input
If IsNull(PhoneNumber) Or Me.PhoneNumber = 0 Or Me.PhoneNumber = "" Then
MsgBox "Phone Number incorrect ! "
Me.PhoneNumber.SetFocus
Exit Sub
End If
'Check if Address lines have been input
If IsNull(Address1) Or Me.Address1 = "" Or Me.Address1 = "" Then
MsgBox "Address incorrect ! "
Me.Address1.SetFocus
Exit Sub
End If
If IsNull(Address2) Or Me.Address2 = "" Or Me.Address2 = "" Then
MsgBox "Address incorrect ! "
Me.Address2.SetFocus
Exit Sub
End If
' If IsNull(Address3) Or Me.Address3 = "" Or Me.Address3 = "" Then
' MsgBox "Address incorrect ! "
' Me.Address3.SetFocus
' Exit Sub
' End If
DoCmd.Close
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub