AutoExec in Access Database invoked from


I was wondering if the automagic macro "AutoExec" would still run if the database is opened from as a data source?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not if you open it as a data source (you'd be tapping into the tables, but not the forms, queries, reports,code, etc)

However it WOULD run your auto exec if you opened/navigated to it through other means from your VB.Net app, such as a hyperlink control.  That would effectively be automating a double-click on the file itself.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I believe so if ...
You use the OpenCurrentDatabase method. When the target DB opens, the AutoExec will run.

I have a database loader app - an Access MDE. It copies a Front End master from the server to a local workstation, then opens the db, and the loader closes.

When the OpenCurrentDatabase executes, the Auto Exec macro in the db that is opening immediately runs. And in fact, the loader will not close until the AE macro is finished.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
As the others have said, no.

You need to be running an instance of MSAccess.exe in some way to have the autoexec work.

No points here please...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
No Points wanted here either...

I was wondering if the automagic macro "AutoExec" would still run if the database is opened from as a data source?
If by this you mean the data ("tables") are stored in a app, then yes Autoexec will still run.  Autoexec is just a piece of automation that runs, (at it simplest, it can just be a messagebox that says "The database is now open")
So in most cases the data-source will not effect it.

However, if the data in the .net is not available, ...and Autoexec needs this info, it may fail...
For example, it runs code to display total sales:
msgbox Dsum("Sales", "YourVBNetTable")
If the table is not available, then the macro may error out...

prositAuthor Commented:
Thank you for all your answers!

Splitting the points...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.