Recordset.Open and WHERE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All.....


Is there a correct format for using the Recordset.Open function WHERE
CustomerID = Me.CustomerID

I want to open a recordset from 'tblOrders' and only select orders that
match the customerID.

Am I looking at the wrong function, is there an easier way to do this?

Thanks.
 
Hi Paul,

I usually construct a sql statement to open recordsets
for cases like this. Something like the following:

Dim db as DAO.Database
Dim rst as DAO.Recordset
Dim strSQL as String

Set db = CurrentDB

strSQL = "SELECT * FROM YourTable WHERE CustomerID = " &
Me.CustomerID

Set rst = db.OpenRecordset(StrSQL)

There are some other optional parameters that you can
specify in the OpenRecordset method, which you can read
about it help, but I think that should get you going in
the right direction.

-Ted Allen
 
Back
Top