autoexec as vba?

access10000

Registered User.
Local time
Today, 23:50
Joined
May 31, 2007
Messages
25
Please could someone tell me how to perform autoexec in vba? Is there a function name or startup property that needs to be used? I need to run this without using an autoexec macro or running code off the back off a form at startup. I have searched the net and tried the obvious things, (autoexec(), autostart() etc.)

Many thanks

:confused:
 
Those are the only ways I know of; is there a reason you don't want to use one of them?
 
I'm trying to move away from using macros, and am finding an increasing need to use VB, mde files and make my systems more secure. As macros can't be locked I want to be able to run the entire code in VBA.

At the moment I set a form to open at startup and run code on it's open event to immediately close the form and then continue running the rest of the code. I'm just looking for a better way as I don't necessarily need a form opening to be the first process.

I know it's not a massive deal to do that but I hate having things in processes where i don't need them.:)
 
On startup you could open the form as hidden, I use this method after an user logs in. This hidden form I call frm_utility stores details e.g. Employee Number etc. about the user that are used whilst the user is using the database. This saves using Dlookup each time and it also stores other reference values that I use for the database.
 
How does your db load up?

1. Is there a splash screen?
2. Is there a switchboard of some sort?
 
Thanks for the responses. Yes the form could be hidden, and I was thinking I could use a startup form as part of a splash etc. sure... The question is a general one and not for a specific db. I'm just looking for a better method.

It may be better if I give an example of a situation. A db which currently uses an autoexec macro, checks the windows username of the person opening the db against a list of authorised users for the db. If the user is not registered then it displays an access denied message and boots them out. This is before it does anything else.

There may also be queries or other checks and processes that need to be run before a form is even opened etc. I'm just looking to eliiminate unnecessary steps and hopefully find a vba function or property to mirror autoexec in macros.

If there really isn't a way I will use hidden forms / splashes etc. but want to look for a method first.

Thanks..
 
These are standard procedures when working in this environment to either use an autoexec macro, embed code within a startup form or call the function before proceeding. There's no workaround. If you don't want to write the code in the form then create a function specifically for that purpose and call the function from any part of your application.
 
For AutoExec you MUST use a macro called AutoExec. However you can use code named AutoExec too and you just call the RunCode action in the AutoExec macro to run the code.

Running on a form is not the same as the AutoExec though. AutoExec runs BEFORE any table links are checked or anything else happens in your database. So, if you want anything to run like that you MUST use a macro named AutoExec. Sorry but you can't get around that one.
 
OK, thanks for all the replies. Thought it was worth exploring..
 

Users who are viewing this thread

Back
Top Bottom