Solved Can not find object '|1'

urjudo

Member
Local time
Today, 05:20
Joined
Oct 9, 2020
Messages
67
Hello,
I'm trying to export a form to PDF and got an error message "Can bot find the object '|1'. What does that mean? The report I tried to export is get data from 10 tables, is because that? I used this code in another forms and it works but don't know why is not working in this form.
here is my code:
Code:
DoCmd.OutputTo acOutputReport, Me.OrderNumber & "-" & rptOrder", acFormatPDF, OutputFile

Thank you for your time
 
What is the value in OutputFile?
 
I tried debug, it shows the OrderNumber but for some reason it keeps give me this error message
 
this looks wrong

Me.OrderNumber & "-" & rptOrder"

suspect it should be

Me.OrderNumber & "- rptOrder"
 
Invariably, the "cannot find '|1' in ..." means that in a query-dependent object (such as but not limited to a report), you have either spelled the name of a field wrong OR you have qualified a field with a table name and you spelled the table name wrong.

EDIT: CJ's comment makes sense too.
 
the name of the report is rptOrder not -rptOrder, I the report save as 1234567-rptOrder. It works if I remove the ordernumber but we need to have the ordernumber to identify the report. I did try Me.OrderNumber & "- rptOrder" and it has the same error message
 
in that case try

DoCmd.OutputTo acOutputReport,"rptOrder", acFormatPDF, "C:\" & Me.OrderNumber & "-rptOrder"

set the path to what you want.

Always helps to google the method/function/whatever so you know what each of the parameters mean

 
I tried debug, it shows the OrderNumber but for some reason it keeps give me this error message
Hi. Just in case it matters, can you show us the actual value of OutputFile?
 
sorry, I was wrong. I took it back what I mention before. I just realized that the code was not working in another form either. Is any other way to save reports with modified report name?

Thanks
 
sorry, I was wrong. I took it back what I mention before. I just realized that the code was not working in another form either. Is any other way to save reports with modified report name?

Thanks
Hi. This would be the third time I ask this question. Can you show us the value I requested twice before? Otherwise, maybe consider sharing a copy of your db.
 
Sorry, here is the screen shot
1607047362491.png
 
Messages like that can be due to having the name of an object such as a control or form the same as that of a module or the database itself.
 
DoCmd.OutputTo acOutputReport, "rptOrder", acFormatPDF, Me.OrderNumber & "-rptOrder.pdf"
 
I agree with The_Doc_Man. Gives this error due to inaccuracies in domain names.
 
@urjudo - do reread the whole thread - a number of suggestions and questions have been asked which you are ignoring. You certainly don't appear to have tried the suggestions
 
@all , sorry , I wasn't trying to ignore any suggestions or questions, if I make you feel that way, please forgive me. I might have missed reading one or two replies but I would never ignore. I respect each of you for your knowledge and skills and appreciate your assistance. I sent the screen shot to show theDBGuy that the value outputfile if I didn't misunderstand what he is asking.
 
I sent the screen shot to show theDBGuy that the value outputfile if I didn't misunderstand what he is asking.
In your original post, you showed us a piece of VBA code that has OutputFile as a variable. I was asking what value did you assign to it.

To show us that value, you could have either shown us the line:

OutputFile="c://folder/filename.pdf"

or the result of:

Debug.Print OutputFile

Instead, you decided to show us a screenshot of what looks like a macro, and you only showed us half of it, so we can't really tell what could be missing or wrong with that macro.
 
@theDBguy,
I did not assigned the location of the OutputFile because I don't know where the users want to save the reports to, that's why I leave open. But I think I show assign the location, correct?

@arnelgp,
I tried your method, it works the way I want , but one more question, is there a way to specify where to save the newly name file?

Thanks all
 
@all,
I think I got it works now.
I set a location as FilePath then use @arnelgp's method:

FilePath = Environ("userprofile")\OneDrive\Order-PDF Forms\"
DoCmd.OutputTo acOutputReport, "rptOrder", acFormatPDF, FilePath & Me.OrderNumber & "-rptOrder.pdf"
Report(s) saved to the specific folder now.

Thank you so much to all for your time to helped me! Very appreciated!
 
@all,
I think I got it works now.
I set a location as FilePath then use @arnelgp's method:

FilePath = Environ("userprofile")\OneDrive\Order-PDF Forms\"
DoCmd.OutputTo acOutputReport, "rptOrder", acFormatPDF, FilePath & Me.OrderNumber & "-rptOrder.pdf"
Report(s) saved to the specific folder now.

Thank you so much to all for your time to helped me! Very appreciated!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom