PDA

View Full Version : access to excel docmd.transferspreadsheet



blammo04
06-14-2010, 09:50 AM
Set db = CurrentDb()
db.QueryDefs("strSoftwareNameOI").SQL = "SELECT Software.[Software Name], Software.Version, Software.[Operating System], " & _
"Software.Status, Software.[Status Date], Software.[Approved Platforms], " & _
"Software.[Code Type], CUsage.[Cost Center], CUsage.[Entered On] " & _
"FROM Software INNER JOIN CUsage " & _
"ON Software.[Software Name] = CUsage.[Software Name] " & _
"AND Software.Version = CUsage.Version " & _
"AND Software.[Operating System] = CUsage.[Operating System] " & _
"WHERE Software.[Software Name] = '" & strSoftwareNameOI & "' " & _
"AND Software.Version = '" & strVersionOI & "' " & _
"AND Software.[Operating System] = '" & strOSOI & "' "


DoCmd.TransferSpreadsheet acExport, , "strSoftwareNameOI", "C:\Documents and Settings\mjw\Desktop\testing.xls", True




The transferspreadsheet doesnt work, does anyone know a reason as to why it will not work?

Thanks!

CreganTur
06-14-2010, 12:58 PM
What error number and message are you getting?

blammo04
06-14-2010, 01:06 PM
no error message, Access just locks up and I get the program is not responding and have to exit out of it and click end now.

It works if i use docmd.outputto acOutputQuery but I cant use that because I need multiple queries to go into one excel file.

I dont know whats wrong with it, i've tried everything that I know of

CreganTur
06-15-2010, 09:54 AM
I would imagine that the error is caused because the querydef hasn't completed updating by the time your next line of code attemtps to export the data in Excel. I would suggest creating that as an actual query object in your database- that will take away this possibility.

blammo04
06-15-2010, 09:59 AM
How would I go about creating it as a query object?

CreganTur
06-15-2010, 12:54 PM
just create a new query using the query designer.