Output to xls

KenHigg

Registered User
Local time
Today, 02:27
Joined
Jun 9, 2004
Messages
13,327
I have a sql string that is used to populate a form and now I'd like to export that set of records to a spreadsheet but I can't get 'OutputTo' to work. It wants a predefined query name - !? Any suggestions?
 
In Access, saved your SQL statement as a query. It should then work.

Regards
Mark
 
View, Design View, File Save As
 
I build the sql string in code and the set a forms recordsource to the sql string. What command do you use to save a sql string as a query?
 
First just create a query object so that you can manipulate the SQL. Then you can open the querydef in code and update the SQL Statement. Something like below would work or at least give you and idea

Dim def As QueryDef

Set def = CurrentDb.QueryDefs("queryName")

def.SQL = "SQLstring"
 
Thanks Mark & Keith - I got this to work with the QueryDef thing - :)
 

Users who are viewing this thread

Back
Top Bottom