DoCmd OutputTo Error

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

"The Object Type argument for the action ormethod is blank or invalid"

I get the above error when I tried to execute this code:
Private Sub cmdImportFiles_Click()
Dim testQry As String, fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room Templates\DAILY
WAR ROOM LOG.xls"
'Qry = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007# ORDER
BY NAME"
DoCmd.OutputTo acOutputQuery, Query1, acFormatXLS, fileLocation, True
End Sub

I don't know what it is I did wrong, or am doing wrong. Please help.
Thank you.
 
Ayo said:
"The Object Type argument for the action ormethod is blank or invalid"

I get the above error when I tried to execute this code:
Private Sub cmdImportFiles_Click()
Dim testQry As String, fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room
Templates\DAILY WAR ROOM LOG.xls"
'Qry = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#
ORDER BY NAME"
DoCmd.OutputTo acOutputQuery, Query1, acFormatXLS, fileLocation,
True End Sub

I don't know what it is I did wrong, or am doing wrong. Please help.
Thank you.

Query1 needs quotes around it.
 
Ayo,
You have dimmed Query1 As String
You have used Query1 as the query to Output
You have not told the code what Query1 is, because you used Qry instead of
Query1

If you put Query1= "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#
ORDER
BY NAME"

the code will probably work.

Jeanette Cunningham
 
I tried your suggestion and I got a "can't find the object...." error

Private Sub cmdImportFiles_Click()
Dim fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room Templates\DAILY
WAR ROOM LOG.xls"
Query1 = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#" & "
ORDER BY NAME"
DoCmd.OutputTo acOutputQuery, "Query1", acFormatXLS, fileLocation, True
End Sub


Rick Brandt said:
Ayo said:
"The Object Type argument for the action ormethod is blank or invalid"

I get the above error when I tried to execute this code:
Private Sub cmdImportFiles_Click()
Dim testQry As String, fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room
Templates\DAILY WAR ROOM LOG.xls"
'Qry = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#
ORDER BY NAME"
DoCmd.OutputTo acOutputQuery, Query1, acFormatXLS, fileLocation,
True End Sub

I don't know what it is I did wrong, or am doing wrong. Please help.
Thank you.

Query1 needs quotes around it.
 
Ayo said:
I tried your suggestion and I got a "can't find the object...." error

Private Sub cmdImportFiles_Click()
Dim fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room
Templates\DAILY WAR ROOM LOG.xls"
Query1 = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#"
& " ORDER BY NAME"
DoCmd.OutputTo acOutputQuery, "Query1", acFormatXLS, fileLocation,
True End Sub

The code above is not the same as in the post I responded to and I was
assuming that Query1 was a saved query since the assingment to Qry was
commented out. If Query1 is a variable name then it does not belong in
quotes, but your original code had no string assigned to Query1.
 
Thanks

Rick Brandt said:
Ayo said:
I tried your suggestion and I got a "can't find the object...." error

Private Sub cmdImportFiles_Click()
Dim fileLocation As String, Query1 As String
fileLocation = "E:\Database Work In-Progress\War Room
Templates\DAILY WAR ROOM LOG.xls"
Query1 = "SELECT * FROM tblConstructionLog WHERE [DATE]=#9/4/2007#"
& " ORDER BY NAME"
DoCmd.OutputTo acOutputQuery, "Query1", acFormatXLS, fileLocation,
True End Sub

The code above is not the same as in the post I responded to and I was
assuming that Query1 was a saved query since the assingment to Qry was
commented out. If Query1 is a variable name then it does not belong in
quotes, but your original code had no string assigned to Query1.
 
Back
Top