Find or move to previous record

A

azu_daioh

How do I move to the previous record?

I have an unbound control (findDoctor) where the user could type in
the doctor's last name. The matching record is displayed in the bound
controls with the doctor's license number, last name, first name,
specialty.

There are two buttons, first is the "find" button:

findMe = "*" & Me.findDoctor & "*"
DoCmd.GoToControl "drLName"
DoCmd.FindRecord findMe

The 2nd button is labeled "next":
findMe = "*" & Me.findDoctor & "*"
DoCmd.GoToControl "drLName"
DoCmd.findnext

But once I clicked on the "next" button there is no way to move back
to the previously found record. I tried DoCmd.GoToRecord , ,
acPrevious but of course that moved me to the previous record on file
but not the previously matching record.

Any help is appreciated. Thank you,
 
K

Ken Sheridan

How about filtering the form with:

Dim strFilter As String

strFilter = "drLName Like ""*" & Me.findDoctor & "*"""

Me.Filter = strFilter
Me.FilterOn = True

All records will then match the search criterion so you can move back and
forth through them at will. To show all records turn off the filter with:

Me.FilterOn = False

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top