By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,365 Members | 3,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,365 IT Pros & Developers. It's quick & easy.

TransferSpreadsheet using a Query

P: n/a
Hello,

I use TransferSpreadsheet on a daily basis using a Table as a
datasource. I was under the impression from reading Help that you could
also use a Query as the datasource. This is my code: (simplified here)

strSQL = "SELECT [Part Number] FROM [Orders];"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, strSQL,
Path, True

I get an error message:
Microsoft could not find the object: "SELECT [Part Number] FROM
[Orders];"

I tried saving it as a query and used the Query Name and got the same
result.

What am I missing?
Thanks,
Hank Reed

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 10 Aug 2005 07:15:12 -0700, Hank wrote:
Hello,

I use TransferSpreadsheet on a daily basis using a Table as a
datasource. I was under the impression from reading Help that you could
also use a Query as the datasource. This is my code: (simplified here)

strSQL = "SELECT [Part Number] FROM [Orders];"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel7, strSQL,
Path, True

I get an error message:
Microsoft could not find the object: "SELECT [Part Number] FROM
[Orders];"

I tried saving it as a query and used the Query Name and got the same
result.

What am I missing?
Thanks,
Hank Reed


This works for me.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"tblMileage", "C:\Practice\ExcelPractice\Practice2.xls", True

"tblMileage" is the name of the query.
Did you place yours within quote marks?

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2

P: n/a
Fred,

Perfect, but, of course its "qrySaveForecast"

Never occured to me to delimit it with quotes.

I prefer embedded SQL statements but this works.

Thanks,
Hank Reed

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.