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:
  1. Dim db As DAO.Database
  2. Dim qdf As DAO.QueryDef
  3. Dim rst As DAO.Recordset
  4.  
  5. Set db = CurrentDb
  6. Set qdf = db.QueryDefs("querycheck")
  7. qdf.parameters(0) = "Cashiering"
  8. 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.