If the form I am using already has a record using a specific number, I want the user to be aware before they enter all the info. I found this code and it works except when it redirects me to the existing record, it doesn't. It redirects me to record #1. The field booking number is not a PK or AutoNumber field. It is a number field and as you can imagine, each is very specific to each person. Using that number as the PK field just won't work for this application. What I would like to accomplish is to be redirected to an existing booking number if it exists, otherwise the user will just fill in the form as needed. Here's what I have"
CODE:
[Private Sub Booking_Number_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.BookingNumber.Value
stLinkCriteria = [BookingNumber] = " & " '" & SID & "'"
'Check tblClient table for duplicate BookingNumber
If DCount("*", "tblClientInfo", "[BookingNumber]=" & Me.BookingNumber) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Booking Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Booking Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub]
Any help will be greatly appreciated