Others

Fix Microsoft Access AutoExec Macro Cannot Find a Function

Bushra ParveenBushra Parveen Nov 20, 2026 868 views

Question details

The user needs an AutoExec macro to find and run a relink function when an Access database opens.

Fix Microsoft Access AutoExec Macro Cannot Find a Function
Product
Microsoft Access
Device & OS
not provided
Scenario
An AutoExec macro uses the RunCode action to call a function such as Reconnect to relink database tables.
Observed behavior
Access reports that it cannot find the function called by the macro.
Before you start

Open the database with startup actions bypassed if necessary by holding Shift while opening it, provided the bypass key is enabled. Identify the function name and arguments in the AutoExec macro's RunCode action.

Solution 1Recommended

Make the relink function available to the AutoExec macro

Use this solution when RunCode cannot find the function named in the startup macro.

1
Open the VBA editor

In Access, press Alt+F11 to open the Visual Basic Editor, then locate the relink procedure in the Project Explorer.

2
Use a standard module

If the procedure is in a form or report module, choose Insert > Module and move the procedure into the new standard module. Name the module something distinct, such as modRelink, using the Properties window.

3
Declare a public function

Ensure the procedure is declared as a Public Function, not a Sub. For a function without arguments, the declaration can start with Public Function Reconnect() and end with End Function. Keep the existing relink logic inside the function.

4
Check the macro expression

Open the AutoExec macro in Design View and check the RunCode action's Function Name field. Enter Reconnect() for a function with no arguments, or supply the arguments required by your function. Ensure its name differs from the module name and other Access object names.

5
Compile and test

In the VBA editor, choose Debug > Compile and resolve any reported errors. Save the changes, reopen the database normally, and check whether AutoExec runs the function.

Make the relink function available to the AutoExec macro
Test the oldest supported version: If Access 2010 is the oldest supported version, test the database in Access 2010 to catch version-specific compatibility issues.
Free Microsoft Office alternative

Work with Office Documents in WPS Office

WPS Office is a free, lightweight alternative for everyday documents, spreadsheets, and presentations. Its familiar interface and Microsoft Office format compatibility make it easier to move routine work between suites. It does not run Access AutoExec macros or fix Access database errors.

Edit documents, spreadsheets, and presentations in one lightweight suite.Open and save common Microsoft Office formats, including DOCX, XLSX, and PPTX.Use a familiar interface for a smoother transition from Microsoft Office.Keep working with exported spreadsheet data while troubleshooting an Access database.
microsoft office alternative - wps office

Frequently Asked Questions

Why can't AutoExec find my Reconnect procedure?

RunCode needs a callable public function. In the VBA editor, check that Reconnect is declared as a Public Function in a standard module and that the macro's Function Name field calls it with the required arguments.

Can an Access RunCode action call a Sub?

RunCode calls a function rather than a Sub. Change the procedure to a Public Function in a standard module, then update the RunCode expression and compile the project.

Does the module name matter?

Yes. Give the standard module a name distinct from the function and other Access objects. For example, use modRelink for a module containing the Reconnect function.

How do I check for a missing VBA reference?

Press Alt+F11, choose Tools > References, and look for an entry marked MISSING. Remove it only if it is unnecessary, or select the appropriate available library if the code depends on it.

How can I open the database without running AutoExec?

Hold Shift while opening the database to bypass startup actions, if the database allows the bypass key. You can then inspect the AutoExec macro and VBA code.