yvette,
Sorry, I did not pay enough attention.
Let's take a little different approach.
Try this code:
Dim strSelectedVal As String
Dim varRecCnt
strSelectedVal = Me.SelectMRN
varRecCnt = DCount("NameOfYourId", "NameOfYourTable", _
"MRN= '" & strSelectedVal & "'")
If varRecCnt = 0 Then
MsgBox "Sorry, that patient is not a current patient.", , "No record
found"
Else
Set rs = Me.Recordset.Clone
rs.FindFirst "[MRN] = '" & strSelectedVal & "'"
Me.Bookmark = rs.Bookmark
End If
This is just a different way of determining if there is a record already in
the table and providing feedback to the user or taking action.
--
HTH
Mr B
askdoctoraccess dot com
yvette said:
Thanks for the suggestion but it doesn't seem to work. The message doesn't
pop up when the record is not found.
:
yvette,
Try:
Private Sub SelectMRN_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MRN] = '" & Me![SelectMRN] & "'"
If Not rs.EOF Then
Me.Bookmark = rs.Bookmark
Else
MsgBox "Sorry, that patient is not a current patient.", , "No
record found"
End If
End Sub
HTH
Mr. B
askdoctoraccess dot com
:
Thanks Jeff. Sorry for the spastic moment.
I want to insert
MsgBox "Sorry, that patient is not a current patient.", , "No record found"
Below is the existing VBA code:
Private Sub SelectMRN_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[MRN] = '" & Me![SelectMRN] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
:
Yvette
The code you included seems a little ... sparse ...
Regards
Jeff Boyce
Microsoft Office/Access MVP
I have a form that pulls up a record that matches a control. I used the
form
wizard to do this. Below is the VBA code. How do I modify the VBA code
so
that a message box will appear if someone tries to pull up information for
a
record that doesn't exist?