Private Sub Form_Current()
If Me.NewRecord Then
[B][COLOR="Red"]Me.ReferenceID = DMax("RefID", "tblPatientInfo") + 1
Me.PatientIs.SetFocus[/COLOR][/B]
Me.FirstName.Locked = False
Me.LastName.Locked = False
Me.Gender.Locked = False
Me.IDCardNumber.Locked = False
Me.DateOfBirth.Locked = False
Me.EntryDate.Locked = False
Me.EntryTime.Locked = False
Else
...
Forms!Mainform.Requery
Forms!frmmain!SearchResults.Requery
Dim msgResponse As String
If Me.NewRecord Then
If IsNull(Me.FirstName) And IsNull(Me.PatientIs) And IsNull(Me.Gender) And IsNull(Me.InsuranceCompany) Then
Me.Undo
DoCmd.Close acForm, "frmNewPatient"
ElseIf IsNull(Me.FirstName) Or IsNull(Me.PatientIs) Or IsNull(Me.Gender) Or IsNull(Me.InsuranceCompany) Then
MsgBox "There is missing missing Data " & _
"All field indicated by a red astrisk must " & _
"Be completed"
msgResponse = MsgBox("If you wish to save this record click YES and provide the missing data " & _
"Otherwise click NO to clear the form and cancel", vbYesNo)
If msgResponse = vbYes Then
Cancel = True
Exit Sub
Else
Me.Undo
DoCmd.Close acForm, "frmNewPatient"
End If
End If
DoCmd.Close acForm, "frmNewPatient"
End If