Ms-access: do something in the database open

Is it possible to run a sub or function as soon as the user opens the access database file? if so, how?

+6
vba ms-access
source share
2 answers

Create your function:

Public Function DoSomething() ' do stuff ' End Function 

Then create a macro with the action of a startup code that calls your DoSomething function. Name the macro autoexec. Then, every time the database starts up, it runs your autoexec macro.

Another thing you can do is set up a form to open when the database starts. Then you can call the DoSomething function from the form event (when opening or loading).

Choose one of these approaches. In any case, if you ever want to start the database without starting DoSomething, hold down the shift key when the database opens to bypass your automatic startup procedure.

+13
source share

You can open a hidden form at startup, as in Access 2007 Startup . This is also possible with an older version of Access.

You can use this hidden form for logging or other system-related tasks.

+2
source share

All Articles