FindLast method

cbialzik

Registered User.
Local time
Today, 13:04
Joined
Feb 21, 2006
Messages
15
I'm trying to use the FindLast method to look up a patient's last visit by visitid when adding a new visit. When I add a new visit I would like it to look up their last visit and use the values in some of the fields as the default value of the new visit. Does that make sense? The visitid is an autonumber. I have found several examples online and in my books but no luck.
an example of one of my many attempts (I am not a VB programmer):
dim rst as recordset
dim strcriteria as string
strcriteria = "visitid="""" & visitid & """"
set rst=me.recordsetclone
rst.findlast strcriteria
if not rst.nomatch then
BPRx=rst!BPRx
end if

Any help would be great!
 
I write using ADO rather than DAO so I'm not going to write the code for you but this is what you need to do:

Firstly, you need to know the patient's ID which I can't see in your code.

Now you need a SELECT statement to filter out your patient from the table. This might be something like:

Criteria = "SELECT visitid,DateOfVisit,Complaint FROM tblData WHERE PatID = " & me.PatientBox.Value & " ORDER BY visitid"

Opening the recordset on this will give you all visits by the patient in the order he made them. Now:

rst.MoveLast - you are now pointing at the last record of your table and can pull whatever field data you want (Having included the fields in your select statement of course)
 
Thanks for responding Summerwind. ADO code is fine too. I was just using DAO because that is the code I found. I do have it finding the patient's ID. I just didn't include that part. I will give this a try.
 

Users who are viewing this thread

Back
Top Bottom