To resolve this issue, refresh the references. You can either refresh the references manually or you can use code to refresh the references.
Refreshing the References Manually
- Open the database that you are working with.
- In the Database window, click Modules under Objects.
- If there is already a module there, open it in Design view. If you do not have any modules in your database yet, click New.
- In the Visual Basic Editor, click References on the Tools menu.
- Click to select any reference that is not already selected. Remember the name of the reference, and then click OK.
- On the Tools menu, click References.
- Click to clear the reference that you selected in step 5, and then click OK.
- On the File menu, click Close and Return to Microsoft Access.
Now you can run the code that previously caused Access to quit.
Using Code to Refresh the References
To use code to refresh the references, create the following command button on a form:
- In the Database window, click Forms under Objects, and then click New.
- Click Design View, and then click OK.
- If the toolbox is not visible, click Toolbox on the View menu.
- Add a command button to the form.
- If the Properties dialog box is not visible, click Properties on the View menu.
- Click the Event tab, click the On Click property, click the down arrow, click [Event Procedure], and then click the Build (...) button.
- Type or paste the following code in the subroutine:
Dim r As Reference, r1 As Reference
Dim s As String
' Look for the first reference in the database other
' than Access and Visual Basic for Applications.
For Each r In Application.References
If r.Name <> "Access" And r.Name <> "VBA" Then
Set r1 = r
Exit For
End If
Next
s = r1.FullPath
' Remove the Reference and add it back.
References.Remove r1
References.AddFromFile s
' Call a hidden SysCmd to automatically compile and save all modules.
Call SysCmd(504, 16483)
- On the File menu, click Close and Return to Microsoft Access.
- Close the form and save the change.
When you want to reset the references, open the form, and then click the command button.
NOTE: If the database is part of a replica set, you must apply this code to the Design Master. Then, run the code when the project component of the database (for example, forms, reports, and modules) is changed. Finally, synchronize the database with the replica.