Cannot execute a select query.

J

Julie R.

In a module I have a Sub called generateSCHConFile(). I
create a string with the query. Then I call
CurrentDb.Execute string. I get the following message
Run-time error '3065 Cannot execute a select query. Does
anyone have a clue?
 
D

Douglas J. Steele

Like the message says, the Execute method doesn't work with Select queries
(nor does DoCmd.RunSQL). Both methods work only with Action queries (i.e.
Delete, Insert Into or Update)

If you explain what you're trying to do, perhaps someone will be able to
suggest an alternative.
 
J

Julie R.

From this Sub I am trying to get a record set. I will put
this data into an array, manipulate it, then write it out
to a text file.
 
D

Douglas J. Steele

In that case, you need to use OpenRecordset method of the Database object
(assuming DAO), or the Open method of the Recordset object (assuming ADO)
 
J

Julie R.

That worked thanks!
-----Original Message-----
In that case, you need to use OpenRecordset method of the Database object
(assuming DAO), or the Open method of the Recordset object (assuming ADO)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)






.
 
Top