开发者

ms-access: doing something on database open

开发者 https://www.devze.com 2023-01-04 14:18 出处:网络
is it possible to run a sub or function as soon as the user opens an a开发者_如何学Pythonccess database file? if so, how?Create your function:

is it possible to run a sub or function as soon as the user opens an a开发者_如何学Pythonccess database file? if so, how?


Create your function:

Public Function DoSomething()
    ' do stuff '
End Function

Then create a macro with the run code action which calls your DoSomething function. Name the macro autoexec. Then, every time the data base starts up, it will run your autoexec macro.

Another thing you can do is set a form to open whenever the database starts. You could then call your DoSomething function from a form event (on open, or on load).

Choose one of those approaches. Either way, if you ever want to start the database without DoSomething running, hold down the shift key as the database opens to bypass your automatic startup routine.


You could open a hidden form on start up like in Access 2007 Startup. This is also possible in older Access version.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消