I have a command button that, when pressed searches through a table (ClientInfo) and checks if there is a record for a specific patient. Currently I have it working so that you can search for a specific ClientNumber (unique for each patient) and that is working fine. Unfortunately not everyone has a ClientNumber and I'm trying to also incorporate a DOB ( Birth Date ) search. It seems to be finding the record fine, but won't then navigate to it. Can anyone help? Below is the code for the Sub...
(txtClientSrch is where the DOB is entered that you are searching for...)
Dim rst As Recordset, myBookmark As String
Set rst = CurrentDb.OpenRecordset("SELECT * FROM ClientInfo"
On Error Resume Next
rst.MoveFirst
txtClientSrch.SetFocus
MyValue = txtClientSrch.Text
Do While Not rst.EOF
If rst.Fields("DOB" = MyValue Then
myBookmark = rst.Bookmark
Exit Do
End If
rst.MoveNext
Loop
If rst.Fields("DOB" <> MyValue Then
MsgBox "No record for that patient", vbInformation, "LMTC Database"
txtClientSrch.Text = " "
txtClientSrch.SetFocus
Exit Sub
End If
Me.RecordsetClone.FindFirst "[DOB] = " & MyValue
Me.Bookmark = Me.RecordsetClone.Bookmark
End
(txtClientSrch is where the DOB is entered that you are searching for...)
Dim rst As Recordset, myBookmark As String
Set rst = CurrentDb.OpenRecordset("SELECT * FROM ClientInfo"
On Error Resume Next
rst.MoveFirst
txtClientSrch.SetFocus
MyValue = txtClientSrch.Text
Do While Not rst.EOF
If rst.Fields("DOB" = MyValue Then
myBookmark = rst.Bookmark
Exit Do
End If
rst.MoveNext
Loop
If rst.Fields("DOB" <> MyValue Then
MsgBox "No record for that patient", vbInformation, "LMTC Database"
txtClientSrch.Text = " "
txtClientSrch.SetFocus
Exit Sub
End If
Me.RecordsetClone.FindFirst "[DOB] = " & MyValue
Me.Bookmark = Me.RecordsetClone.Bookmark
End