How To Convert Access Report To PDF File

Summary:

Our today’s topic of discussion is about how to convert Access report to pdf file. Besides that you will get idea on how to import/export Access report to pdf and much more…!

Many of you must have used MS Access to store several of your information but do you know you can add files to your Access database also? Well MS Access makes this tough task simple by defining a special attachment fields that hold complex data. If you are willing to use the PDF file in Access database then check out this post.

As it is specifically written with the main prospective to provide you all with every pinch of information regarding how to convert MS Access report to pdf file, Import PDF Files into Access Database and export Access report to multiple pdf files.

How To Import PDF Files Into Access Database

How To Import PDF Files Into Access Database

You can import pdf file in Access database simply by adding it from attachment field. Learn how it is to be done. Here we will perform this in two sections, so that you can understand it more clearly.

1: By Adding An Attachment Field

2: Add PDF To Table

Step 1: By Adding an Attachment Field

  1. At first open your MS Access database and after then go to the Navigation pane.
  2. Now make a right-click on the Access table within which you need to add your PDF document.
  3. Tap to the “Design View” option. You will see that Access will display a table having name of the field on it. Scroll down to this table and go to a blank row having no field name on it.
  4. Keep your mouse cursor on that particular row’s Field Name column. After then assign name for this attachment field. Suppose, you want to keep the field name PDF for easy identification then type PDF over there.
  5. Just next to the name you have recently assigned you will see one drop-down menu of Data Type will appear to you. So, from this drop down menu choose the “Attachment” data type. After then press the “Ctrl+S” for saving up all the changes done by you.

Step 2 :Add PDF to Table

After make the table in database it’s time to insert PDF document into Access Database table.

  1. From the menu bar of your Access database tap to the “View” tab. After then tap to the “Datasheet View.” Keeping your table in datasheet view, will help you in easy updating of the data in the table.
  2. Now come to that row which is having the record that you want to update. Suppose, you need to add your PDF document into the 20th row, then you need to scroll to that row.
  3. Go to the attachment field which you have added in the step 1. Now make double tap on that field for opening of the dialog Window of Attachments.
  4. Hit on the Add option and this will open the Window of Choose File. From this Window you can choose your PDF attachment file.
  5. After the selection of the PDF file you want to add in your Access table. Tap to “Open” button and then on “OK” option.

You will see that your PDF file is get added into the row of the table which you have selected.

How To convert Access Report To PDF

How To convert Access Report To PDF

After learning how to open or import pdf file in Access database. It’s time to move into our next section i.e how to convert Access report to PDF file.

Here is the step to convert Access report to pdf file. Follow it carefully:

  • Open your Access report.
  • After then go to your Access database menu bar Ribbon. Here tap to the External Data tab and then from the Export group choose the PDF or XPS option.

convert Access Report To PDF

  • Choose the file or folder path where you want to save your Access pdf file.
  • After then tap to the Publish.

convert Access Report To PDF 1

  • Tapping to the publish option will automatically open Access report in PDF file format.

All done…! Now you can see that your Access report is successfully converted to PDF file format.

Isn’t it easy…!

If you need to perform this task on regular basis then it becomes quiet irritating to perform this manual step. At that time you need some simple solution. With which in just one single click you can immediately export Access report to PDF file.

So, in our next step we will learn how to export Access report to PDF using VBA.

How To Export Access Report To PDF File Via VBA

How To Export Access Report To PDF File Via VBA

In this section of my post you will learn about how to design a VBA function that help you to convert Access report to PDF file in just one single click of the button.

Now you need not to go every time on your Access menu bar to convert Access report to pdf.

Steps For Making A VBA Function Which Saves The Access Report In PDF File Format

How To Export Access Report To PDF File Via VBA

1. Add One Command Button Within Your Report

Try the following method if you are already having an Access report. If it’s not then make it first.

Open your Access database design view and then add one button on Report header section. Just as shown in figure.

Export Access Report To PDF File Via VBA 1

Assign the name of this button as cmd_exportPDF. For this perform the following steps:

  1. In the design view, choose the button.
  2. Press the ALT + Enter button from your keyboard to open the Property Sheet.
  3. Now tap to the Other tab and then on the Name
  4. After then you need have change your Name value to this; cmd_exportPDF.

2. Add code for the command button

For adding up the code, you firstly need to add one On_Click event on the button.

  1. Keeping the above cmd button selected, once again go to the Property Sheet.
  2. Tap on the Event
  3. Search for On Click and then select…
  4. You will see a Choose Builder menu gets pops up on your screen. Select Code Builder and tap to the OK
  5. After this VBA Editor gets open on your screen.

You have to just copy the below code.

Remember: you have to update the values for file name &  folder Path. You can see in the comment section, each one have an asterisk (*).

Function FileExist(FileFullPath As String) As Boolean
Dim value As Boolean
value = False
If Dir(FileFullPath) <> “” Then
value = True
End If
FileExist = value
End Function

Private Sub cmd_exportPDF_Click()

Dim fileName As String, fldrPath As String, filePath As String
Dim answer As Integer

fileName = “Member Contact Details” ‘filename for PDF file*
fldrPath = “C:\Users\Jessica\Desktop\PDF Exports” ‘folder path where pdf file will be saved *

filePath = fldrPath & “\” & fileName & “.pdf”

‘check if file already exists
If FileExist(filePath) Then
answer = MsgBox(prompt:=”PDF file already exists: ” & vbNewLine & filePath & vbNewLine & vbNewLine & _
“Would you like to replace existing file?”, buttons:=vbYesNo, Title:=”Existing PDF File”)
If answer = vbNo Then Exit Sub
End If

On Error GoTo invalidFolderPath
DoCmd.OutputTo objecttype:=acOutputReport, objectName:=Me.Name, outputformat:=acFormatPDF, outputFile:=filePath

MsgBox prompt:=”PDF File exported to: ” & vbNewLine & filePath, buttons:=vbInformation, Title:=”Report Exported as PDF”
Exit Sub

invalidFolderPath:
MsgBox prompt:=”Error: Invalid folder path. Please update code.”, buttons:=vbCritical

End Sub

These lines of code will:
  1. Check whether the PDF file having the same file name already present within the specified folder.

If it is there, then you will get a prompt message asking regarding replacement of old file with the new one will comes up on your screen.

At this time if you select the “yes” option then your export Access report PDF process will continued. If you press the “No” option then the process of conversion will be stopped.

  1. Suppose you have entered one folder path which doesn’t exist. At that time you will get a message regarding updating of the folder path specified in the code. Process of exporting access report to PDF will not be continued until and unless it is been corrected.
  2. After the successful exportation of the Access report, you will get a message indicating that “your PDF file is successfully saved now”.

Now it’s time to make a trial to your button.

Points To Remember While Converting Access Report To PDF File

Converting Access Report To PDF File

Tips:

  • If you are in Access Design mode, then you can see any of your PDF file just making double tap on the field having the PDF. After then tap to the “Open” option.
  • An icon of paper clip appears on the field having attachments. It will also show the number of attachment in that particular field.
  • After the attachment of the field in the table it’s impossible to convert it into some other data type. So, delete that particular field if you don’t require it.

Wrap Up:

Now you must have got enough idea on how to use PDF file with Access database.  So, perform any operation of converting, importing and exporting of PDF file in your Access database effortlessly.

If you are finding, theses manual steps tricky and tough then you can approach for online conversion of Access file to pdf using the Access to PDF converter online.

If meanwhile performing these steps, unfortunately if you encounter any issue then share it with us. So, that I can help you out to fix that.

How To Convert Access Report To PDF File