AccessAllAreas
Member
- Local time
- Today, 23:06
- Joined
- Jul 20, 2020
- Messages
- 42
Dear Experts
Thank you for your patience.
I have another issue when trying to implement form-level validation. This is a bound form that can both be used to displat records and input new infor ation for volunteers.
Goal: To avoid duplicate records by comparing LastName concatenated with the entry for FirstName, but then, After a MessageBox has been shown and OK selected, the duplicate record is displayed for the purposes of comparison.
Form:
Relevant Controls:
VolunteerId (referr to field in table contain Primary key)
LastName
FirstName
Existing VBA code (I have taken it from the web - it manages to get to the point of recognising the duplicate record, but does not display the exisiting record that the LastName and FirstName combination matches):
Once again, thanks in advance. I am sure it js easy. But beyond me, I am afraid.
Thank you for your patience.
I have another issue when trying to implement form-level validation. This is a bound form that can both be used to displat records and input new infor ation for volunteers.
Goal: To avoid duplicate records by comparing LastName concatenated with the entry for FirstName, but then, After a MessageBox has been shown and OK selected, the duplicate record is displayed for the purposes of comparison.
Form:
Relevant Controls:
VolunteerId (referr to field in table contain Primary key)
LastName
FirstName
Existing VBA code (I have taken it from the web - it manages to get to the point of recognising the duplicate record, but does not display the exisiting record that the LastName and FirstName combination matches):
Code:
Private Sub Volunteer_First_Name_BeforeUpdate(Cancel As Integer)
Dim NewVolunteer As String
Dim strLinkVolunteerCriteria As String
Dim VolunteerNo As Integer
NewVolunteer = Me.Volunteer_Surname.Value & Me.Volunteer_First_Name.Value
strLinkPublisherCriteria = "'" & NewPublisher & "'"
If (Me.Volunteer_Surname & Me.Volunteer_First_Name) = DLookup(("[Volunteer Surname] & [Volunteer First Name]"), _
"Tab_Emergency_Contact_List", strLinkVolunteerCriteria) Then
MsgBox "The publisher name that you are trying to add, " & NewVolunteer & ", already exists in the database." _
& vbCrLf & vbCrLf & "Please check the record displayed to confirm whether you wish to add this person as a unique individual." _
& vbCrLf & vbCrLf & "Please make the Surname and First Name combination are unique compared with existing publisher record.", _
vbInformation, "Duplicate Volunteer Record"
Me.Undo
Else
DoCmd.RunCommand
End If
VolunteerNo = DLookup("VolunteerID", "Tab_Emergency_Contact_List", strLinkVolunteerCriteria)
Me.DataEntry = False
Me.PublisherID.SetFocus
DoCmd.FindRecord PublisherNo, , , , , acCurrent
End Sub
Once again, thanks in advance. I am sure it js easy. But beyond me, I am afraid.