Using a variable in a query or filter?

M

Maury Markowitz

Access 2003, all coding in VB.

I'm sure this is very easy, but...

I have a form that uses some simple SQL in the Record Source line to
populate a few fields. Nothing very interesting there.

I have a DLL that returns the login name of the user running my Access
application. This seems to work fine, and I place it into a variable called
"loggedInUser"

What I would like to do is filter the recordset on the form to only those
records that match the value in the variable. For instance...

SELECT * FROM tblOrders WHERE userId = loggedInUser

I assume there is some simple syntax for this, like @loggedInUser@ or
whatever, but I don't have any examples of it.

What's the key here? And should I put the query into the Filter field
instead? If so, what is the syntax there?
 
Top