Access 2007 - macro to run when the file is opened

Posted on 2014-07-25
Last Modified: 2014-07-25
My OS is win 7 prof 64 bit and I use Access 2007.  I am trying to create a Macro which will run (it will open the main Form) when I open the Access file.  What should be the name of the Macro, and is there any special extensions to the name.  Thank u.
Question by:jegajothy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 334 total points
ID: 40219787
Just name it AutoExec

 as long as the shift key is not held down, it will run.

LVL 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 334 total points
ID: 40219791
By the way, don't miss the startup form in Options either; you don't have to use a macro.

LVL 38

Assisted Solution

PatHartman earned 166 total points
ID: 40219799
When a database is opened, Access looks for a macro named specifically - AutoExec.  If the macro exists, Access runs it.

You also have the option of specifying a start up form to use rather than a macro.  The form can serve the function of the AutoExec by running whatever code/queries/macros you need to run at startup.  If you specify a "Display Form" on the Current Database tab of the Access Options dialog, you do not need to create an AutoExec macro.  Although Access allows both to be specified, you don't need both.  Just settle on one (my preference is code in a form) so you won't get confused later and end up splitting start up functions so some run in one place and others in another.

Author Closing Comment

ID: 40220431
thank u everyone for your suggestions, AutoExec was what i was looking for, as it gives me more options of running other maintenance issues before the main Form displays.  Thanks u everyone.
LVL 38

Expert Comment

ID: 40220457
Actually, it doesn't.  But as long as you don't define both an AutoExec and a start up form, you'll be fine.  Just open the start up form as the last step of the macro.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question