Recordset

muno37
04-19-2004, 09:46 AM
Ok, this is really simple, and probably already been explained before, but I have a Recordset that I need to export into an Excel file.
Do I have to use a Do While !rs.eof loop to export the entire record set and loop through the recordset one record and column at a time, or is there an easier way to do this? If I do have to loop through, what exactly are the functions for doing this? I would imagine I need rs.MoveFirst before the loop is started but how do you move from record to record?

Thanks

couch612
04-19-2004, 06:19 PM
if you are doing this in Access, here is a simple way of doing it:


'you can also use acSpreadsheetTypeExcel8, acSpreadsheetTypeExcel7 etc.
'setting the last parameter to True includes the Field names in the Excel file
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "MyTable", "MyTable.xls", True

MKoslof
04-19-2004, 06:50 PM
You can also use an SQL statement and export this directly into Excel.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum