My problem is that Access freezes up whenever I try to use the docmd.transfers preadsheet method, I can use the docmd.outputto and it works fine but I need to be able to use the transferspreads heet method so I can have multiple queries in one excel file.
If anyone can help as what the problem may be, I would greatly appreciate it.
If anyone can help as what the problem may be, I would greatly appreciate it.
Code:
strReps = "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 & "' "
Set db = CurrentDb()
Set qry = db.CreateQueryDef("strSoftwareNameOI", strReps)
If DCount("*", "strSoftwareNameOI") > 0 Then
'MsgBox "NOT Empty"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "strSoftwareNameOI", "C:\Documents and Settings\jmayhew\Desktop\testing.xls", True
db.QueryDefs.Delete ("strSoftwareNameOI")
Else
'MsgBox "Empty"
db.QueryDefs("strSoftwareNameOI").SQL = "SELECT Software.[Software Name], Software.Version, Software.[Operating System], " & _
"Software.Status, Software.[Status Date], Software.[Approved Platforms], " & _
"Software.[Code Type], Space(30) = '0' AS [Cost Center], Space(30) = '0' AS [Entered On] " & _
"FROM Software " & _
"WHERE Software.[Software Name] = '" & strSoftwareNameOI & "' " & _
"AND Software.Version = '" & strVersionOI & "' " & _
"AND Software.[Operating System] = '" & strOSOI & "' "
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "strSoftwareNameOI", "C:\Documents and Settings\jmayhew\Desktop\testing.xls", True
db.QueryDefs.Delete ("strSoftwareNameOI")
End If
Comment