Hi,
I'm new here and in VBA as well and was wondering if you can help .
I´ve created a simple database to register visitors. The main table is called Visitors. In that table there´s a YES/NO field data (AccessDenied) for denied access.
Whenever there's a recurring visit (same LastName, FirstName and DOB) and the denied access box is selected, I'd like a popup message triggered in this denied access data.
So far, this code is working to detect duplicate data (names and DOB) but not for the YES/NO field data...
this is to be used in a data insertion form.
Thank you in advance!
here's the code
Private Sub DOB_AfterUpdate()
Call CheckData
End Sub
Private Sub FirstName_AfterUpdate()
Call CheckData
End Sub
Private Sub LastName_AfterUpdate()
Call CheckData
End Sub
Private Sub Nationality_AfterUpdate()
Call CheckData
End Sub
Sub CheckData()
Dim criteria As String
criteria = "LastName='" & LastName & "' And FirstName='" & FirstName & "'" & " And DOB=#" & _
Format(DOB, "dd/mm/yyyy") & "#"
If Not IsNull(LastName) And Not IsNull(DOB) And Not IsNull(FirstName) Then
If IsNull(VisitorID) Then
VisitorID = DMax("VisitorID", "Visitors") + 1
End If
If DCount("VisitorID", "Visitors", criteria) > 0 Then
MsgBox "This visitor has been denied access!”
End If
End If
End Sub