longestdrive
Programmer
Hi,
I'm what is best described as a stumbler....from one issue to another. Most I resolve through other posts but I'm stuck on this one.
I have a form which allows the user to specify criteria. After clicking a search button the search results are displayed. The query is created within the form.
I can successfully open a report with the search results.
I want to now export the search results direct to excel. I've unsuccessfully tried a couple of versions here and am settling on the TransferSpreadsheet method. Here is my code so far:
I'm what is best described as a stumbler....from one issue to another. Most I resolve through other posts but I'm stuck on this one.
I have a form which allows the user to specify criteria. After clicking a search button the search results are displayed. The query is created within the form.
I can successfully open a report with the search results.
I want to now export the search results direct to excel. I've unsuccessfully tried a couple of versions here and am settling on the TransferSpreadsheet method. Here is my code so far:
Code:
Private Sub btn_ExportExcel_Click()
Dim rst As Recordset
Dim strfilename As String
Dim strpath As String
strpath = CurrentProject.path
strfilename = strpath & "\profiles report.xls"
Set rst = Me.RecordsetClone
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, rst, strfilename, True
[CODE]
I get an error message:
Wrong data type for one of the arguments in the TransferSpreadsheet line.
Any advice, pointers where I'm going wrong or whether there is a simple answer?
I think it's around the recordsetclone part - although not sure
My version of Access is 2003
Thanks