Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export of Query to Spreadsheet

Status
Not open for further replies.

GummowN

Programmer
Jul 26, 2002
157
GB
I am not sure whether I am just being blind but I am having a few problems with the following code:

qryname = ("qsel_reportresults" & runno)
Set qdf = dbs.CreateQueryDef(qryname)
qdf.SQL = sqlstr
dbs.QueryDefs.Refresh

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, qryname, filestr, True

Runno is an integer, and sqlstr is a string.

Access returns err 3011 could not find object qsel_reportresults19.

However, I can do a Docmd.openquery qryname.

Any advice would be most welcome.
 

The one thing I would check is your concatenation of your numeric value to a text string.

For example, if the numeric value is 12 and your computed string is “runqry12” and the name you are expecting is runqry0012 you know what the problem is. I would set a break point right after the line with the concat statement and look at the returned string.

Just a quick thought.
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top