Can not find object (1 Viewer)

Gismo

Registered User.
Local time
Today, 21:28
Joined
Jun 12, 2017
Messages
1,298
Hi all,

Please could you assist?
Having an Error on below code

1637223200584.png


Private Sub DownloadDawSheet_Click()
On Error GoTo DownloadDawSheet_Click_Err


DoCmd.OutputTo acReport, ("DAW Sheet - Comm Approve" & " - Registration -" & " " & Forms![CS Raised - Mail]![RegCBO]), acFormatPDF, vReportPDF

DownloadDawSheet_Click_Exit:

'DoCmd.SetWarnings False
'DoCmd.OpenQuery "Update CS Commercial Mailed to Yes"
'DoCmd.Close
'DoCmd.Close "Menu"
'DoCmd.OpenForm "Menu"
'DoCmd.SetWarnings False
Exit Sub

DownloadDawSheet_Click_Err:
MsgBox Error$
Resume DownloadDawSheet_Click_Exit

End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:28
Joined
Sep 21, 2011
Messages
14,237
Why not put all that second parameter into a string variable. and debug.print it. Then when correct use that instead? I would expect any object with spaces in it's name to be enclosed within [ & ], and you have been here long enough to know that? :(
Plus undeclared variables?
Do you Option Explicit at the top of each module?

 

Gismo

Registered User.
Local time
Today, 21:28
Joined
Jun 12, 2017
Messages
1,298
Why not put all that second parameter into a string variable. and debug.print it. Then when correct use that instead? I would expect any object with spaces in it's name to be enclosed within [ & ], and you have been here long enough to know that? :(
Plus undeclared variables?
Do you Option Explicit at the top of each module?


I do have Option Explicit in place

when i use below code, it works perfect

DoCmd.OutputTo acReport, "DAW Sheet - Comm Approve", acFormatPDF, vReportPDF

When i use below code, I get an error
DoCmd.OutputTo acReport, ("[DAW Sheet - Comm Approve]" & " - Registration -" & " " & Forms![CS Raised - Mail]![RegCBO]), acFormatPDF, vReportPDF
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:28
Joined
Sep 21, 2011
Messages
14,237
Yes, I know, you have already said that. :(

So do what I suggested?
Put "[DAW Sheet - Comm Approve]" & " - Registration -" & " " & Forms![CS Raised - Mail]![RegCBO] into a string variable and debug.print it to see what you get.

This is basic 101 Access debugging :(
 

Gismo

Registered User.
Local time
Today, 21:28
Joined
Jun 12, 2017
Messages
1,298
Yes, I know, you have already said that. :(

So do what I suggested?
Put "[DAW Sheet - Comm Approve]" & " - Registration -" & " " & Forms![CS Raised - Mail]![RegCBO] into a string variable and debug.print it to see what you get.

This is basic 101 Access debugging :(
When I put the object in brackets, the file save as file name then also displays the brackets

1637234279349.png



I get to this stage of saving option and once I click on ok, i get the can find object error

Still looking in to the debug.print

1637234344357.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:28
Joined
Sep 21, 2011
Messages
14,237
Check your arguments for the command.
LOOK at the link I posted.
 

Minty

AWF VIP
Local time
Today, 19:28
Joined
Jul 26, 2013
Messages
10,368
The second argument is the report name, not what you want to call the output.

If you really have reports with the registration details as part of their name I'd be surprised?
 

Gismo

Registered User.
Local time
Today, 21:28
Joined
Jun 12, 2017
Messages
1,298
The second argument is the report name, not what you want to call the output.

If you really have reports with the registration details as part of their name I'd be surprised?
Hi,

Yes i merge the report name with the registration in all my save as file, makes referencing to the correct file easier
 

Gismo

Registered User.
Local time
Today, 21:28
Joined
Jun 12, 2017
Messages
1,298
Check your arguments for the command.
LOOK at the link I posted.
I Checked the link
My code works well when I dont link to the forms control

Only when I code to add the registration from the form I get the error
 

Minty

AWF VIP
Local time
Today, 19:28
Joined
Jul 26, 2013
Messages
10,368
@Gismo please read the link again.
You don't have a report called
DAW Sheet - Comm Approve - Registration - ZT-RDP

Do you ? You want to call the file that.
With 900 + posts I would expect you to understand the file name goes in the 4th argument.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 13:28
Joined
Feb 28, 2001
Messages
27,146
Whenever you see "|1" in an error message, it refers to the first thing in a list of some things. I have seen "|2" and "|3" at different times. In queries, it is usually a bad spelling or bad location for a field. In other calls, it is whatever is the first parameter. What is ACTUALLY wrong? I don't know offhand but you got some advice about your error. But where to look? The first element of whatever you are passing in!
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:28
Joined
Sep 21, 2011
Messages
14,237
Why not comment that out and start again.
Use the intellisense to get arguments in the correct place?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:28
Joined
Feb 19, 2002
Messages
43,229
As the others have mentioned, building the string into a variable and then printing the variable will very likely show you or at least us, what the syntax error is. So, start with that.
 

Users who are viewing this thread

Top Bottom