Urgent Help - Passing parameters to a table query
Hi,
I need to complete a report and show to my boss in a few hrs. and hence the urgency.
I have a table query (designed in access) which asks for a parameter "UnitName" and then executes creating a table. The query works fine from access. I now need to run the query from vba passing the parameter "UnitName". I am trying the code below but it is giving me the error "Runtime error 3219 invalid operation" on the line marked below. I think it is because I am trying to execute a table query since other forms of query seems to be running fine.
VB Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Set db = CurrentDb
Set qdf = db.QueryDefs("querycheck")
qdf.parameters(0) = "Cashiering"
Set rst = qdf.OpenRecordset <-------- error here
I will appreciate any help or any other code for passing the parameters. thanks. I don't mind using ado too.