Display PDF File Names in a Microsoft Access List Box
Question details
Display the names of PDF files from a folder in a list box on a Microsoft Access form.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A form needs to show the PDF files available in a specified folder.
- Observed behavior
- The list box should show the PDF file names when the form opens.
Identify the folder containing the PDFs and the name of the list box on your form. Make sure the folder path is accessible and that VBA content is enabled for the database.
Populate the Access list box with VBA
Use the Dir function to add PDF file names when the form opens.
Open the form in Design View, select the list box, and open the Property Sheet. On the Other or All tab, check its Name; this example uses lstPDFs.
In the list box Property Sheet, open the Data tab and set Row Source Type to Value List. Clear the Row Source property so the code can populate it.
Select the form using the Property Sheet selection drop-down. On the Event tab, set On Load to [Event Procedure], then click the ellipsis button to open the VBA editor.
In the Form_Load procedure, add the following lines. Replace C:\PDFs\ with your folder path, retaining the final backslash, and replace lstPDFs with your list box name: Dim folderPath As String Dim fileName As String folderPath = "C:\PDFs\" Me.lstPDFs.RowSource = "" fileName = Dir(folderPath & "*.pdf") Do While fileName <> "" Me.lstPDFs.AddItem fileName fileName = Dir() Loop
Save the form and open it in Form View. Confirm that the list box shows the PDF file names from the specified folder.

Use an Access table as the list box row source
Use a table-backed list when you need to manage or filter a larger collection of PDF names.
Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for viewing PDFs and working with common Office files, making it easy to move everyday document work to WPS. It does not replace Microsoft Access or run the Access form and VBA solution.

Frequently Asked Questions
How do I find my list box's name in Access?
Open the form in Design View, select the list box, and open the Property Sheet. Look for Name on the Other or All tab.
Where is the Row Source Type setting?
Select the list box in Design View, open the Property Sheet, and choose the Data tab. Set Row Source Type to Value List for the VBA AddItem method.
Will the VBA code include PDFs in subfolders?
No. Dir(folderPath & "*.pdf") searches only the specified folder. Searching subfolders requires additional code.
How do I refresh the list after adding a PDF?
Close and reopen the form to run its Load event again. Alternatively, move the listing code into a reusable procedure and call it from a refresh button.
Does selecting a file name open the PDF?
No. The example only displays names. Opening a selected PDF requires a separate event procedure that combines the folder path with the selected name and opens that file.




