Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching a recordset for specific date

Status
Not open for further replies.

eussias

Programmer
Sep 25, 2001
97
AU
Can anyone help??!! I've been trying to get this code below to work, and for some reason it's fully working... The user enters a Date into the txtDate text box and when the Command Button is clicked the recordset is serched, looking for a matching DOB. When the record is found it drops out of the loop, but for some reason is not navigating to the record.
Skep has been trying numerous things, and as yet we have had no success. Any help would be greatly appreciated!! :cool:

Dim rst As Recordset
Dim myBookmark As Date
Set rst = CurrentDb.OpenRecordset("ClientInfo", dbOpenDynaset)
On Error Resume Next
rst.MoveFirst
Dim MyValue As Date
MyValue = txtDate
Do While Not rst.EOF
If rst.Fields("DOB") = MyValue Then
myBookmark = rst.Bookmark
Exit Do
End If
rst.MoveNext
Loop
If rst.Fields(&quot;DOB&quot;) <> MyValue Then
MsgBox &quot;No record for that patient&quot;, vbInformation, &quot;LMTC Database&quot;
txtClientSrch.Text = &quot; &quot;
txtClientSrch.SetFocus
Exit Sub
End If
Me.RecordsetClone.FindFirst &quot;[DOB] = &quot; & MyValue
Me.Bookmark = Me.RecordsetClone.Bookmark
 
Hi!

Don't declare myBookmark, do this instead:

Me.Bookmark = rst.Bookmark

That should take your form to the same record as the recordset. Another thought, from your code I assumed that the rst was searching the same set of information as the form displays. To be sure of that you should use:

Set rst = Me.Recordsetclone

hth Jeff Bridgham
bridgham@purdue.edu
 
If you do fancy declaring it, Bookmarks are Variants.

M :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top