Solved

Access 2007 - macro to run when the file is opened

Posted on 2014-07-25
5
1,363 Views
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.
0
Comment
Question by:jegajothy
  • 2
  • 2
5 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 334 total points
Comment Utility
Just name it AutoExec

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

Jim.
0
 
LVL 57

Assisted Solution

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

Jim.
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 166 total points
Comment Utility
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.
0
 

Author Closing Comment

by:jegajothy
Comment Utility
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.
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now