O
OssieMac
I have the following code that I thought should export my data from a
continuous form to an Excel Spreadsheet. The sql statement basically emulates
that which is used within my continuous form as the forms record source.
However, on
the "DoCmd.TransferSpreadsheet...." line I get the following error:-
Runtime error '2498'
An expression you entered in the wrong data type for one of the arguments.
So what I thought would be simple just isn't working and I have come to the
conclusion that I can't use record set for the parameter in lieu of a table
name.
Any help in pointing me in the right direction will be greatly appreciated
because I have been searching for answers and just not finding exactly what I
need.
Private Sub Export_To_Excel_Click()
Dim sqlStatement As String
Dim strPath As String
Dim strFileName As String
Dim strFilePath As String
Dim dBs
Dim rs
sqlStatement = "SELECT [PrefixAndId], [Association1], [Product]," & _
"[ProductDescription] FROM [DonatedProducts] " & _
"WHERE ([DonatedProducts].[ReceiptOut]= " & _
Forms![Receipts Out Tracking]![ReceiptOut] & ") " & _
"ORDER BY Left(DonatedProducts!PrefixAndId,1)," & _
"DonatedProducts.ProductID;"
Set dBs = CurrentDb
Set rs = dBs.OpenRecordset(sqlStatement)
strPath = "C:\Documents and Settings\Database"
strFileName = "TestExport.xls"
strFilePath = strPath & "\" & strFileName
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, rs, strFilePath
End Sub
continuous form to an Excel Spreadsheet. The sql statement basically emulates
that which is used within my continuous form as the forms record source.
However, on
the "DoCmd.TransferSpreadsheet...." line I get the following error:-
Runtime error '2498'
An expression you entered in the wrong data type for one of the arguments.
So what I thought would be simple just isn't working and I have come to the
conclusion that I can't use record set for the parameter in lieu of a table
name.
Any help in pointing me in the right direction will be greatly appreciated
because I have been searching for answers and just not finding exactly what I
need.
Private Sub Export_To_Excel_Click()
Dim sqlStatement As String
Dim strPath As String
Dim strFileName As String
Dim strFilePath As String
Dim dBs
Dim rs
sqlStatement = "SELECT [PrefixAndId], [Association1], [Product]," & _
"[ProductDescription] FROM [DonatedProducts] " & _
"WHERE ([DonatedProducts].[ReceiptOut]= " & _
Forms![Receipts Out Tracking]![ReceiptOut] & ") " & _
"ORDER BY Left(DonatedProducts!PrefixAndId,1)," & _
"DonatedProducts.ProductID;"
Set dBs = CurrentDb
Set rs = dBs.OpenRecordset(sqlStatement)
strPath = "C:\Documents and Settings\Database"
strFileName = "TestExport.xls"
strFilePath = strPath & "\" & strFileName
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, rs, strFilePath
End Sub