TransferSpreadsheet

J

Justin

Users want to download data from my database to excel. I would like to use a
sql string that gets created. Is there any way to use a string or string
variable instead of a saved query? If not, haw can I save the string to a
query?
 
C

Craig

Justin,
On this below you can give the new QueryDef a blank name.
SQL="SELECT * FROM Customers"
set qd=db.CreateQueryDef("",SQL)
qd.OpenRecordset

On this one you can assign SQL string to the stored query.
SQL="SELECT * FROM Customers WHERE CustomerID =1"
set qd=db.QueryDefs("qryCustomer")
qd.SQL=SQL
qd.OpenRecordset
 
J

Justin

Craig

Sorry, I'm not very strong in this area. What data type should I set db to?

Thanks for the assistance,
Justin
 
Top