Output a recordset

Michelangelo

Registered User.
Local time
Today, 11:53
Joined
Dec 20, 2002
Messages
37
Hi,

I want to export a recordset which I created at runtime to a Excel table.

I tried to use docmd.outputto .. statement but I can't get it to work.

Code:
Dim rst as Recordset

Set rst = CurrentDB.OpenRecordset("SELECT * FROM strTable WHERE [Name] Like '*', dbOpenSnapshot)

DoCmd.OutputTo acOutputTable, rst, acFormatXLS, "D:\test.xls"

It returns a error telling me that datatypes do not match in the Docmd statement. I think it is because the rst is a Recordset Object and there should be a string value pointing to a Table in the DB.

The same goes for a querydef object and trying to use de outputto method with acOutputQuery instead of acOutputTable.

Any help is greatly appreciated.
 
Try putting the SQL that the rst is based on into a string variable and using the name of that variable in place of "rst" in the DoCmd statement.
 
I'll try that. Would make it much simpler to not even have have a recordset as an intermediate.
 

Users who are viewing this thread

Back
Top Bottom