I have a Autoexec macro setup on a Access 2016 database to determine which form to open based on Environ("USERNAME")
.
When I open the database I get a macro Error 2001. If I click Stop All Macros, I can continue using the database without issue, until I change the filename, then the issue happens again.
Are there any options to prevent this error from occurring?
The code being called is
LUser = LCase(Environ("USERNAME")) 'Get current username
DoCmd.OpenForm "frmDash", acNormal, , , , acWindowNormal
If IsNull(DLookup("[sysname]", "tblaccmannew", "sysname=" & "'" & LUser & "'")) Then
DoCmd.OpenForm "frmSearch", acNormal, , , , acWindowNormal
Forms!frmDash.Visible = False
End If
Enable the SHIFT key to allow the user to bypass the startup properties and the AutoExec macro. Disable the SHIFT key to prevent the user from bypassing the startup properties and the AutoExec macro. You can set this property by using a macro or VBA code.
An AutoExec macro (a macro that you name AutoExec) runs before any other macros or modules in the database. If you've already created a macro that does what you want to happen when the database starts, just rename the macro AutoExec, and it will run the next time that you open the database.
To edit a standalone macro in Access, right-click the name of the macro to edit in the Navigation Pane. Then select the “Design View” command in the pop-up menu that appears to open the macro design view window. In this view, change the macro actions and arguments, as needed, and then save it again.
You need to "trust" the location of the database.
.
On the File tab, click Options.
In the Access Options dialog box, on the left, click Trust Center.
On the right, under Microsoft Office Access Trust Center, click Trust Center Settings.
In the left pane of the Trust Center dialog box, click Trusted Locations.
To add a network location, in the right pane, select the Allow Trusted Locations on my network check box.
Click Add new location.
In the Microsoft Office Trusted Location dialog box, use one of the following methods:
In the Path box, type the full path of the location that you want to add.
Click Browse to browse to the location.
To specify that subfolders of the new trusted locations should also be trusted, select the Subfolders of this location are also trusted check box.
Optionally, in the Description box, type a description for the trusted location.
(Source)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With