Export query in VBA (1 Viewer)

Krugger

New member
Local time
Today, 14:24
Joined
Feb 11, 2016
Messages
2
I hope someone on the forum can help with my question. I currently have SQL queries that I have been executing through VBA code. I do not have the queries saved in what I call the query module. what I need help with is how do I export the SQL Query to excel. I have looked everywhere and it seems you need to have the queries saved in query module to export. Is that true or can it be exported using VBA? Any help is appreciated.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:24
Joined
Aug 30, 2003
Messages
36,118
Generally true, but you could use Excel automation and CopyFromRecordset to export from a recordset opened on the SQL. Certainly a little more complicated if you haven't used it before.
 

Krugger

New member
Local time
Today, 14:24
Joined
Feb 11, 2016
Messages
2
So all of this gets done within access VBA? I am pretty new to VBA, so can you please send me a sample code snippet as to what you are talking about? Anything to get me started is appreciated.:)
 

Users who are viewing this thread

Top Bottom