Hi,
I'm sorry, the error that I'm getting is a run-time error 3464.
I have the following code to prevent duplicate dates. If the date is a duplicate, it'll bring up a warning message and take me to the record that already exists.
Code:
Private Sub TodaysDate_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.TodaysDate.Value
stLinkCriteria = "[TodaysDate]= #" & "'" & SID & "'"
'Check InsuranceNoticesLog table for duplicate TodaysDate
If DCount("TodaysDate", "InsuranceNoticesLog", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "WARNING: " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to that record.", _
vbInformation, "Duplicate Information"
'Go to record of original Access Bar Code
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
However, the data type in the table is set to date/time because I want the field in the form to show a calendar and prevent users from inputting an incorrect date format.
When I changed the data type to text, the code above works. However, when I change the data type to date/time, it no longer works. I know it has something to deal with using an # or something, but I couldn't look up any sample information online.
Please help.
Thank you very much.