G
Guest
I have a form that on the OnOpen Event has the following code:
'------------------------------------------------------------------------------
Dim strRecSource, strOne As String
strOne = "[05] + [06]"
strRecSource = "SELECT Table2.Account, " + strOne + " AS Field1 From Table2;"
Me.RecordSource = strRecSource
'---------------------------------------------------------------------------------
All is fine and the form opens and displays the records properly.
Then I was thinking I want to export the form recordset to excel. I tried:
DoCmd.TransferSpreadsheet acExport, 8, "strRecSource", "C:\My
Documents\Table2Export.xls", True, ""
And I received an error 3011 saying Access could not find the object
"strRecSource"
How would I make this export work exporting the Me.RecordsetClone without
using a Table or Query object but using the string created here
'strRecSource' or the Recordset.
Note: this is a simple example and the actual SELECT is more complex than
just exporting the table. I just wanted to keep it simple here in the
example.
Thank you for your help.
Steven
'------------------------------------------------------------------------------
Dim strRecSource, strOne As String
strOne = "[05] + [06]"
strRecSource = "SELECT Table2.Account, " + strOne + " AS Field1 From Table2;"
Me.RecordSource = strRecSource
'---------------------------------------------------------------------------------
All is fine and the form opens and displays the records properly.
Then I was thinking I want to export the form recordset to excel. I tried:
DoCmd.TransferSpreadsheet acExport, 8, "strRecSource", "C:\My
Documents\Table2Export.xls", True, ""
And I received an error 3011 saying Access could not find the object
"strRecSource"
How would I make this export work exporting the Me.RecordsetClone without
using a Table or Query object but using the string created here
'strRecSource' or the Recordset.
Note: this is a simple example and the actual SELECT is more complex than
just exporting the table. I just wanted to keep it simple here in the
example.
Thank you for your help.
Steven