DoCmd OutputTo Error

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.
 
R

Rick Brandt

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.
 
J

Jeanette Cunningham

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
 
A

Ayo

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.
 
R

Rick Brandt

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.
 
A

Ayo

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top