Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Macro Error 2001 Autoexec Access Macro

Tags:

vba

ms-access

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
like image 292
bd528 Avatar asked Nov 23 '17 14:11

bd528


People also ask

How do I bypass an Access AutoExec?

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.

What is AutoExec Macro in Access?

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.

How do I fix macros in Access?

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.


1 Answers

You need to "trust" the location of the database.

.

Specify a trusted location (Access 2013 & 2016)

  1. On the File tab, click Options.

  2. In the Access Options dialog box, on the left, click Trust Center.

  3. On the right, under Microsoft Office Access Trust Center, click Trust Center Settings.

  4. In the left pane of the Trust Center dialog box, click Trusted Locations.

  5. To add a network location, in the right pane, select the Allow Trusted Locations on my network check box.

  6. Click Add new location.

  7. 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.

  8. To specify that subfolders of the new trusted locations should also be trusted, select the Subfolders of this location are also trusted check box.

  9. Optionally, in the Description box, type a description for the trusted location.

(Source)

like image 127
ashleedawg Avatar answered Oct 13 '22 19:10

ashleedawg