Report export to PDF doesn't create PDF (1 Viewer)

Chicco

New member
Local time
Yesterday, 16:14
Joined
Jul 25, 2017
Messages
9
Hi all folks,

here am I with my very first question for you.
I tried investigating by myself of course in this forum as well as over the net but couldn't find any useful hint to solve the problem I bumped into.

Here is detail of what happening...

1) I have created a form with a button whose function is (would be... :banghead:) to export a given already created and formatted REPORT
to PDF format and save it on my desktop.

The code behind the command button is the following:

Private Sub Comando0_Click()

On Error GoTo Err_Report_Click

'DoCmd.OpenReport "REPORT_CARBURANTI_LUG-AGO_2017", acViewPreview, acWindowNormal
'DoCmd.OutputTo acOutputReport, "REPORT_CARBURANTI_LUG-AGO_2017", acFormatPDF, "C:\DESKTOP\RPT.pdf", True
DoCmd.OpenReport "AN_VEICOLI", acViewPreview, acWindowNormal
DoCmd.OutputTo acOutputReport, "AN_VEICOLI", acFormatPDF, "C:\DESKTOP\ANV.pdf", True
DoCmd.Close , , acSaveYes
'DoCmd.OutputTo acOutputReport, "REPORT_CARBURANTI_LUG-AGO_2017", acFormatPDF, "C:\DESKTOP\REPORT_CARBURANTI_LUG-AGO_2017" & Format(Date, "mmddyyyy") & ".pdf"


Exit_Report_Click:
Exit Sub

Err_Report_Click:
If Err.Number = 2501 Then
'MsgBox Err.Description
Resume Next
Else

MsgBox Err.Description
Resume Exit_Report_Click
End If

End Sub


When I clicked the button for the first time I was warned with an
ERROR 2501. I tried to catch and skip the error as the above code shows but
no way, the report doesn't export to PDF and nothing of course is saved to
defined location.

Apparently, as shown in attached capture, it seems that is it working
but nothing really happens.

If I try to export the report directly by Access (2010) menu it works fine so it doesn't seem a problem related to PDF drivers or printer.

Anyone willing to shed some light on this subject?

Thanks in advance, have a good day!


P.S.: if I posted in the wrong place, please forgive me, is my first post! ;)
 

Attachments

  • DIALOG_EXPORT_RPT_PDF.jpg
    DIALOG_EXPORT_RPT_PDF.jpg
    92.5 KB · Views: 93

isladogs

MVP / VIP
Local time
Today, 00:14
Joined
Jan 14, 2017
Messages
18,221
You've incorrectly specified the location of the desktop folder
Its in a subfolder for the logged on user e.g. "C:\Users\chicco\Desktop"

It should be something like this:
Code:
DoCmd.OutputTo acOutputReport, "AN_VEICOLI", acFormatPDF, "C:\Users\chicco\DESKTOP\ANV.pdf", True

Also:
1. you don't need to open the report first
2. Try this as your error code
Code:
If Err.Number = 2501 Then Exit Sub

3. Please use the # button when posting code as it makes it much easier to read
 

Chicco

New member
Local time
Yesterday, 16:14
Joined
Jul 25, 2017
Messages
9
Thank you for your reply but your suggestion doesn't solve the problem.
I have also tried to export/save to another location, creating a specific folder (C:\PDFREPORTS) other than desktop and still can't succeed exporting to a PDF file.

If you can think of something else causing the problem, your time and effort is greatly appreciated!

Also, I will keep in mind # button for the code, thanks!;)



You've incorrectly specified the location of the desktop folder
Its in a subfolder for the logged on user e.g. "C:\Users\chicco\Desktop"

It should be something like this:
Code:
DoCmd.OutputTo acOutputReport, "AN_VEICOLI", acFormatPDF, "C:\Users\chicco\DESKTOP\ANV.pdf", True

Also:
1. you don't need to open the report first
2. Try this as your error code
Code:
If Err.Number = 2501 Then Exit Sub

3. Please use the # button when posting code as it makes it much easier to read
 

isladogs

MVP / VIP
Local time
Today, 00:14
Joined
Jan 14, 2017
Messages
18,221
Did you CHECK the location of your desktop folder.
Go into Explorer, then C:\Users and look for your folder - it may not be called chicco!

The code I posted works for me so I can't imagine what else it would be if you have the correct folder

So what does happen when you run the code.
No file but no error?
 

Chicco

New member
Local time
Yesterday, 16:14
Joined
Jul 25, 2017
Messages
9
Good morning Ridders,

thank you for further hints!
Unfortunately, also locating the correct path for my desktop folder, I was unable to save the exported PDF to it.

The good news is that I finally succeeded instead at saving it into another folder within C:\

I don't know... yestarday didn't work and today here is it...
Maybe I was wrong at typing the name of the folder to export to but the important thing is that now I finally have my exported report.

Thank you again for your help, have a nice day ;)
 

isladogs

MVP / VIP
Local time
Today, 00:14
Joined
Jan 14, 2017
Messages
18,221
Glad you got it working.

You should be able to save the PDF to your desktop unless the folder permissions prevent that ... which seems very unlikely.

Try using Access to save something else to that folder e.g. a text file
 

Users who are viewing this thread

Top Bottom