Fix Microsoft Access Report Cannot Find Public VBA Function for Images
Question details
Users encounter parameter prompts or duplicate image outputs when an image control in an Access report tries to call a public VBA function for multiple records.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Generating dynamic images such as unique QR codes for multiple records on a single report page.
- Observed behavior
- The report prompts for a parameter indicating it cannot find the VBA function, or it incorrectly applies the image from the first record to all subsequent records because the function is called during the On Load event.
Verify that your public VBA function is placed inside a standard module rather than a form or report module to ensure it is globally accessible to the entire database.
Bind the VBA Function to the Detail Section's Format or Print Event
Moving the VBA function call from the Report's On Load event to the Detail section's On Format or On Print event ensures the image generates correctly for every individual record.
When a report loads, the On Load event fires only once. If you assign an image or call a function here, Access applies the first record's data to all subsequent records on the page. To generate unique values like distinct QR codes for each row, you must trigger the function as each record is individually formatted or printed.
Right-click your Microsoft Access report in the navigation pane and select Design View.
Click directly on the background of the Detail section to highlight it.
Press F4 to open the Property Sheet on the right side of the screen, and switch to the Event tab.
Locate the 'On Format' or 'On Print' event line, click the ellipsis (...) button next to it, and select Code Builder.
Write your VBA code within this event procedure, passing the current record's data to your public function to dynamically update the Image control's Picture property.

Looking for a Lightweight Office Suite? Try WPS Office
While Microsoft Access is strictly for complex databases, your everyday document processing, spreadsheet analysis, and presentations can be streamlined with WPS Office. It provides a lightweight, highly compatible alternative to Microsoft Office without the subscription fees.

Frequently Asked Questions
Why does my Access report prompt for a parameter when calling a VBA function?
This typically occurs if the function name is misspelled in the Control Source, if the function is declared as Private, or if it is isolated inside a specific form or report module rather than a globally accessible Standard Module.
Why is the same QR code showing for every record on my Access report?
If you assign the image property using the report's On Load event, Access only evaluates the first record. To generate a unique QR code for each record, move the VBA code to the Detail section's On Format or On Print event.
Where should I place a public VBA function so my entire Access database can use it?
You should place global functions in a Standard Module. Go to the Database Tools tab, click Visual Basic, insert a new Module (not a Class Module), and declare your function using the 'Public' keyword.




