Shippwreck
Programmer
Hey All,
I'm trying to export the result of three queries to an excel file. The sheets that the queries need to end up in are named sheets... lets call them apple, pear, orange. Below is the code that i'm using:
Obviously thats just one of them, but they are all identical with only name and SQL changes...
Now here's where it gets interesting... if i run the code and set file_path to the correct file with correctly named sheets, it doesn't put the data there... instead it creates new sheets called apple1, pear1, orange1 etc... ok, so i tried doing it without correctly named sheets and it then says that the sheet objects don't exist...
Additionally the export code is taken from a different project that does exactly the same thing and runs perfectly every day (its a daily report)... its code is below:
That exports perfectly to the sheet called data 1... someone please help as this has been frustrating me for 2 days now...
Really ANY help is appreciated!
Thanks
"Google is god...of the internet" - Me
I'm trying to export the result of three queries to an excel file. The sheets that the queries need to end up in are named sheets... lets call them apple, pear, orange. Below is the code that i'm using:
Code:
strSql = "select query here"
Set rs3 = dbs.OpenRecordset(strSql, dbOpenSnapshot)
With dbs
Set qdf = .CreateQueryDef("tmpapple", strSql)
DoCmd.OpenQuery "tmpapple"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tmpapple", File_path, False, "apple"
.QueryDefs.Delete "tmpapple"
End With
Obviously thats just one of them, but they are all identical with only name and SQL changes...
Now here's where it gets interesting... if i run the code and set file_path to the correct file with correctly named sheets, it doesn't put the data there... instead it creates new sheets called apple1, pear1, orange1 etc... ok, so i tried doing it without correctly named sheets and it then says that the sheet objects don't exist...
Additionally the export code is taken from a different project that does exactly the same thing and runs perfectly every day (its a daily report)... its code is below:
Code:
File_path2 = ahtCommonFileOpenSave()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Main Report", File_path2, False, "data 1"
That exports perfectly to the sheet called data 1... someone please help as this has been frustrating me for 2 days now...
Really ANY help is appreciated!
Thanks
"Google is god...of the internet" - Me