Hi Guys
I have code whch is working fine to the point I need to close this form.
It checks if the record exist in "Visitors Book - Personal" and if it doesn't it just enter it with the visit detail to "Visitors Book - Visits" and closes. Now is there a way that if the record exists it does only records the visits details to "Visitors Book - Visits" and closes. ( By the way I think the DoCmd.CancelEvent doesn't do anything )
here is the module
Private Sub CommandENTER_Click()
Me.PersonalID = DLookup("[ID]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "' AND [Surname] ='" & Forms![VisitorsBookIn]![Surname] & "' AND [Month Of Birth] ='" & Forms![VisitorsBookIn]![Month Of Birth] & "' ")
Dim stExist As String
Dim stNoExist As String
Dim stLinkCriteria As String
Dim I As Integer
I = DCount("[First Name]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "'")
Y = DCount("[Surname]", "[Visitors Book - Personal]", "[Surname] ='" & Forms![VisitorsBookIn]![Surname] & "'")
Y = DCount("[Month Of Birth]", "[Visitors Book - Personal]", "[Month Of Birth] ='" & Forms![VisitorsBookIn]![Month Of Birth] & "'")
If I > 0 And Y > 0 And X > 0 Then
DoCmd.CancelEvent
DoCmd.Close
Else
DoCmd.Close
End If
End Sub
Thanks again
I have code whch is working fine to the point I need to close this form.
It checks if the record exist in "Visitors Book - Personal" and if it doesn't it just enter it with the visit detail to "Visitors Book - Visits" and closes. Now is there a way that if the record exists it does only records the visits details to "Visitors Book - Visits" and closes. ( By the way I think the DoCmd.CancelEvent doesn't do anything )
here is the module
Private Sub CommandENTER_Click()
Me.PersonalID = DLookup("[ID]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "' AND [Surname] ='" & Forms![VisitorsBookIn]![Surname] & "' AND [Month Of Birth] ='" & Forms![VisitorsBookIn]![Month Of Birth] & "' ")
Dim stExist As String
Dim stNoExist As String
Dim stLinkCriteria As String
Dim I As Integer
I = DCount("[First Name]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![VisitorsBookIn]![First Name] & "'")
Y = DCount("[Surname]", "[Visitors Book - Personal]", "[Surname] ='" & Forms![VisitorsBookIn]![Surname] & "'")
Y = DCount("[Month Of Birth]", "[Visitors Book - Personal]", "[Month Of Birth] ='" & Forms![VisitorsBookIn]![Month Of Birth] & "'")
If I > 0 And Y > 0 And X > 0 Then
DoCmd.CancelEvent
DoCmd.Close
Else
DoCmd.Close
End If
End Sub
Thanks again