TransferSpreadsheet Problems

R

RudiK

I am trying to export records based on a query.

DoCmd.TransferSpreadsheet
acExport, , "Query", "C:\test.xls", True

The Query "query" works fine but it does not seem to be
accepted by the "TransferSpreadsheet"-method. I get an
error 7874 which says that the object "query" can not be
found ? Am i doing someting wrong ???
 
R

Roger Carlson

What is the name of your query? According to the command, it is looking for
a query named "Query". Put the actual name of the query in this position.

If it IS named "Query", perhaps there is a naming conflict since "query" is
an Access reserved word. Name it something else.
 
R

RudiK

OK, My query has a different name. I was not planning to
let the whole world see what kind of data i am using. Lets
say the query is named "qryTest". Can you help me in any
way...

Thanks
 
R

Roger Carlson

In that case, it should be:
DoCmd.TransferSpreadsheet acExport, , "qryTest", "C:\test.xls", True

If you want to specify a specific version of Excel, do this:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryTest",
"C:\test.xls", True
 
G

Guest

OK, i got this far but what to do if access says that in
cannot find "qryTest" ? See my first post.....
-----Original Message-----
In that case, it should be:
DoCmd.TransferSpreadsheet
acExport, , "qryTest", "C:\test.xls", True
If you want to specify a specific version of Excel, do this:
DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel8, "qryTest",
 
R

Roger Carlson

Unfortunately, I don't know. That is the correct syntax for the
TransferSpreadsheet method. It should work if you have spelled the name of
the query correctly. One slight possibility is that it might be getting
confused if you have a table and query named exactly the same. Check for
that.

Otherwise, I'm stumped. You might need to create a new database, import ALL
of the objects from the old into the new, and see if it works there. There
might be some corruption in your old database.
 
K

Ki Yi [MS]

Hello,

Are you exporting a select query? You can only export Tables or Select
Queries using the TransferSpreadsheet action.
You can also try DoCmd.OutputTo method.

Hope this helps!

Ki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top