R
Roger Carlson
All right! This one is driving me nuts!
I have this query (Query2):
SELECT Books.ISBN, Books.Title, Books.PubID, Books.Price
FROM Books
WHERE (((Books.Title)=[Enter book])) OR (((Books.PubID)=[Enter PubID]));
I want to open it in code and because it has parameters, I use the
following:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("Query2")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Access returns the error message:
Microsoft Access can't find the name 'Enter book' you entered in the
expression.
Any idea what is going on here? What am I missing?
BTW, I also tried removing one of the parameters ([Enter book]) and it
crashed on [Enter PubID].
I also tried adding a parameters clause:
PARAMETERS [Enter book] Text ( 255 ), [Enter pubid] Short;
SELECT Books.ISBN, Books.Title, Books.PubID, Books.Price
FROM Books
WHERE (((Books.Title)=[Enter book])) OR (((Books.PubID)=[Enter PubID]));
Still no luck.
I have this query (Query2):
SELECT Books.ISBN, Books.Title, Books.PubID, Books.Price
FROM Books
WHERE (((Books.Title)=[Enter book])) OR (((Books.PubID)=[Enter PubID]));
I want to open it in code and because it has parameters, I use the
following:
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("Query2")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset(dbOpenDynaset)
Access returns the error message:
Microsoft Access can't find the name 'Enter book' you entered in the
expression.
Any idea what is going on here? What am I missing?
BTW, I also tried removing one of the parameters ([Enter book]) and it
crashed on [Enter PubID].
I also tried adding a parameters clause:
PARAMETERS [Enter book] Text ( 255 ), [Enter pubid] Short;
SELECT Books.ISBN, Books.Title, Books.PubID, Books.Price
FROM Books
WHERE (((Books.Title)=[Enter book])) OR (((Books.PubID)=[Enter PubID]));
Still no luck.