Using multiple parameters in querydef

G

Gibson

I am trying to use the following incomplete code to open a recordset based
on parameters. There are two parameters, each a field in the form from which
whose module this code comes from.
My question is how do I set the parameters for the code?. Obviously I can'
prm to two separate values.
Does it matter if one parameter is a text data type and the other is a
number?

Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim rsTotInv As DAO.Recordset

Set qdf = db.QueryDefs("qrytblA")

For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rsTotInv = qdf.OpenRecordset
 
A

Albert D.Kallal

Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim rsTotInv As DAO.Recordset

Set qdf = db.QueryDefs("qrytblA")

qdf.Parameters("NameOfParm1") = "New York"
qdf.Parameters("NameOfParm2") = 1234


Set rsTotInv = qdf.OpenRecordset

Note how you do NOT have to surround, or convert the data type (so, I did
NOT have to surround the "new York" string with quotes as you do in sql
strings.
 

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