Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running VBA code at startup -- How??

38 views
Skip to first unread message

Christine Scheu

unread,
Jan 9, 1998, 3:00:00 AM1/9/98
to

how does one run VBA code at startup in access97? is it as simply as
naming a module autoexec or something like that? thanks!

Jim

unread,
Jan 9, 1998, 3:00:00 AM1/9/98
to

In your autoexec macro use the runcode action

Christine Scheu wrote in message <696e67$dqh$1...@interport.net>...

Brendan Reynolds

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to

Hi Christine,

You can do it with an AutoExec macro (not a module) or by putting the code
in the OnLoad event of the startup form. You set a startup form using the
Startup command of the Tools menu.

HTH

Brendan Reynolds
bre...@ireland.zarcrom.com
Zarcrom Web Hosting Services
http://ireland.zarcrom.com

Andrew Semeiks

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to

Best way is to use an autoexec macro to open a main switchboard form.
On this form build command buttons that start VBA code to accomplish
your tasks.

Andy

On 9 Jan 1998 19:08:39 -0500, c-s...@interport.net (Christine Scheu)
wrote:

Pete B

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to

Beg to differ. The best way is to use the autoexec to run the code
directly and let the code open the startup form, as well as do everything
else that needs doing at startup. That is the ONLY thing you should really
ever put in an autoexec macro, the one command to run your startup code
function.
--
Pete B

Andrew Semeiks <sem...@albany.net> wrote in article
<34b76626...@news.albany.net>...

John L. Turner

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to 10326...@compuserve.com

How about the Menu Tools | startup
Select a form that will show the user a pretty picture,
and or some important infomation, set the timer Event to 1
and then in the timer Event
set timer to zero
and then add
My important VB code
...
....
Exit sub

I find the advantages to be:
You can trap all errors in the code module
vs- using a macro

Code does not stop the display of the form
if run in the timer event.

--
http://www.citynet.net/personal/psic
JCI Inc.
2425 Poca River Road South
Poca, WV 25159 voice (304) 776-3675
~~ Just because you do not know the answer, does not mean that someone
else does ~~

LMLinson

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to

In article <696e67$dqh$1...@interport.net>, c-s...@interport.net (Christine
Scheu) writes:

> how does one run VBA code at startup in
> access97? is it as simply as naming a
> module autoexec or something like that?

Even simpler: put the code in the Open event of the
first form you want the user to see; then, on the menu,
Tools | Startup and enter the name of the startup
form; or, just as before, you can name a macro
AutoExec and include a RunCode action to run
the code you want executed first.

John L. Turner

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to Pete B

Hello Pete!
I believe that is a hold over from the Access 2/ 95 days
The problem with that is if you ever end up with a run time version
and the macro fails, then the user is looking at the screen saver.
We try to elimate all macros, the only one that I can not work around
having is the Global key assignments. Any Ideas there.
Regards John T

Pete B wrote:
>
> Beg to differ. The best way is to use the autoexec to run the code
> directly and let the code open the startup form, as well as do everything
> else that needs doing at startup. That is the ONLY thing you should really
> ever put in an autoexec macro, the one command to run your startup code
> function.
> --
> Pete B
>
> Andrew Semeiks <sem...@albany.net> wrote in article
> <34b76626...@news.albany.net>...
> > Best way is to use an autoexec macro to open a main switchboard form.
> > On this form build command buttons that start VBA code to accomplish
> > your tasks.
> >
> > Andy
> >
> > On 9 Jan 1998 19:08:39 -0500, c-s...@interport.net (Christine Scheu)
> > wrote:
> >
> > >

> > >how does one run VBA code at startup in access97? is it as simply as

> > >naming a module autoexec or something like that? thanks!

Andrew Semeiks

unread,
Jan 10, 1998, 3:00:00 AM1/10/98
to

You are correct.

Andy


On Sat, 10 Jan 1998 14:56:16 GMT, "Pete B" <bar...@datatek.com>
wrote:

Pete B

unread,
Jan 11, 1998, 3:00:00 AM1/11/98
to

John
The reason you have that problem when the macro fails is because you are
not doing it correctly. The correct way to use the autoexec is to design
your startup code as a function that returns True if it works and False if
the startup fails for any reason, for example make your function something
like StartApp(). Then, in your autexec, do not run it directly using the
RunCode action; instead, use a conditional macro with one line, Quit/No
Save, and for it's condition use "StartApp() = False". The macro will run
the code to evaluate the condition, and if the condition (your startup
function in code) returns False, it will quit the Access session. If the
startup code succeeds, you're OK.

Works like a charm, if the startup fails, the macro just closes the
application with no macro error display. I confess this is not my design,
I saw it somewhere as a tip and have used it successfully ever since.

As for Autokeys, I too wish there were a way to do that via code, no
workaround I know of, but I have not had any real problems with it either.
--
Pete B

John L. Turner <Turn...@Citynet.net> wrote in article
<34B7CB35...@Citynet.net>...


> Hello Pete!
> I believe that is a hold over from the Access 2/ 95 days
> The problem with that is if you ever end up with a run time version
> and the macro fails, then the user is looking at the screen saver.
> We try to elimate all macros, the only one that I can not work around
> having is the Global key assignments. Any Ideas there.
> Regards John T
>
> Pete B wrote:
> >
> > Beg to differ. The best way is to use the autoexec to run the code
> > directly and let the code open the startup form, as well as do
everything

> > else that needs doing at startup. That is the ONLY thing you should


really
> > ever put in an autoexec macro, the one command to run your startup code
> > function.
> > --
> > Pete B
> >

IndPhantom

unread,
Jan 15, 1998, 3:00:00 AM1/15/98
to

>how does one run VBA code at startup in access97? is it as simply as
>naming a module autoexec or something like that? thanks!

Actually, you need to create a MACRO called autoexec that executes the desired
module or form.
Bob Breece
Accu-Data Computer Services - Software Consulting
http://www.accu-dataindy.com

0 new messages