• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

AutoExec in Access Database invoked from VB.net


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

4 Solutions
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 ArchitectCommented:
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)PresidentCommented:
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...

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 vb.net as a data source?
If by this you mean the data ("tables") are stored in a vb.net 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...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now