I'm a research nurse in neurosurgery. I have a database of brain tumor cases. I wanted to add some code to the medical record number field in my demographics form to (1) alert the user if a medical record number they are trying to enter is already in the database and then (2) take them to that record. Here's the code:
Code:
Private Sub mrNum_BeforeUpdate(Cancel As Integer)
Dim mrn As String
Dim LinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
mrn = Me.mrNum.Value
LinkCriteria = "[mrNum]=" & "'" & mrn & "'"
'Check tblDemographics for duplicate Medical Record Number
If DCount("mrNum", "tblDemographics", _
LinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning that medical record number has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original record
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
The problem is in line 18 "rsc.FindFirst stLinkCriteria". I get a Run-time error 3077 "Syntax error (missing operator) in expression." I've tried everything I know but I can't figure out what I'm doing wrong. Thanks.