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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write data from access query to excel worksheet

Status
Not open for further replies.

dayandow4

Programmer
Jun 23, 2011
1
0
0
US
I am trying to copy data from a query in my database to an excel sheet can anyone tell me why this is not working:



Set rst2 = CurrentDb.OpenRecordset("qryXXXX")

Do Until rst2.EOF
Set workSheet = appExcel.Worksheets("DataSheet" & i)
workSheet.Cells(rst2![CellRow], rst2![CellColumn]).Value = rst2![Value] '******
rst2.MoveNext
Loop

the code bombs on the line with the **** after it and it tells me error: "item not found in this collection"


Thanks ahead of time
 
Do you have a field named "Value" in your recordset? I would change the field name to something like "TheValue" in the query to avoid using a reserved word.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top