FindFirst syntaxt

reburton

Registered User.
Local time
Today, 08:11
Joined
Nov 4, 2013
Messages
46
I can't seem to figure out the proper syntax for the FindFirst method. I am using several variations of this effort:

Dim dbs As dao.Database
Dim rst As dao.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblInvoice", dbOpenDynaset)
rst.FindFirst "rst!ID = frmInvoice!txtID"

I get an error message that says that Access doesn't recognize rst.ID as a valid field. But, it most certainly is. I tried substituting tblInvoice but got the same error. What am I doing wrong? :confused:
 
Try..
Code:
rst.FindFirst "ID = " & frmInvoice!txtID
 
And way more efficient:

Set rst = dbs.OpenRecordset("SELECT * FROM tblInvoice WHERE ID = " & frmInvoice!txtID, dbOpenDynaset)

though that doesn't look like a valid form reference:

http://www.mvps.org/access/forms/frm0031.htm
 
Thanks! That did it, but I wish I had a better handle on the syntax of the commands. Nothing I have ever read or seen in the VBE has ever suggested stringing together a line like that. Any suggested reading or anything? :banghead:
 

Users who are viewing this thread

Back
Top Bottom