Accessing query through vb

D

Dan

Hi,

I am trying to open a query through vb and copy its data
to be transfered into an excel spread sheet, but I get an
error message "There was an error executing the command."
when the program reaches set rst = qd.OpenRecordset. I
can not figure out why I am getting this. The code I
have so far is:


Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qd As DAO.QueryDef
Dim varResults

Set db = CurrentDb
Set qd = db.QueryDefs("qry_Backlog For V-Cone")
Set rst = qd.OpenRecordset '<----!!!Crashes here!!!

varResults = rst.GetRows(800)

rst.Close
Set rst = Nothing
Set qd = Nothing
Set db = Nothing

Does anybody know why? How can I fix this?

Thank you.
 
G

George Nicholson

The syntax used in the Help file would be:

Set rst = qd.OpenRecordset ()

(i.e., try adding a pair of empty parentheses)
 

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