VBA - Autoexec Macro Replacement?? 
Author Message
 VBA - Autoexec Macro Replacement??

Hi

is there a way of running the auto exec macro as code not a macro

i want to create a Access 97 MDE File, and would like the Autoexec macro
replaced with a module function so as not to expose the events of the
autoexec to the user!

also...

i'd like to stop the user from adding any new objects to  the MDE File (i.e.
Tables, Queries, Macros)

is there a WithEvents or similar to check and prevent when a new object is
added to an Access database??

Thanks

Jado



Sun, 15 May 2005 19:32:22 GMT  
 VBA - Autoexec Macro Replacement??
First, convert the nacro to VBA code. (There's a built-in method to do
that for you -- IIRC -- in Access 97 and newer.)

Then add the code to a form which you set up to be opened when the
database is opened. This is also somewhere in the menus of Access 97,
although MS likes to move things around and I forget where it was in
that version of Access.

The steps will then be:
    - user opens database
    - database opens form specified by designer
    - form's OnOpen event calls code

HTH,
--

    National Library of Canada
 -- Nothing in the above should be construed to represent
    anything other than my own opinions and personal reality. --


Quote:
> Hi

> is there a way of running the auto exec macro as code not a macro

> i want to create a Access 97 MDE File, and would like the Autoexec
macro
> replaced with a module function so as not to expose the events of the
> autoexec to the user!

> also...

> i'd like to stop the user from adding any new objects to  the MDE File
(i.e.
> Tables, Queries, Macros)

> is there a WithEvents or similar to check and prevent when a new
object is
> added to an Access database??

> Thanks

> Jado



Sun, 15 May 2005 20:44:40 GMT  
 VBA - Autoexec Macro Replacement??
Hi Darryl

i thought that might be the only way to do this...

so i've done all that, but for some reason my Startup Form wont hide when i
use the command

Me.Visible = False

Any Ideas??

Thanks

Jado



Sun, 15 May 2005 21:18:00 GMT  
 VBA - Autoexec Macro Replacement??
If your Form is a PopUp Form, it won't work.

Otherwise, I tested the Me.Visible = False in the Open, Load and Current
Event and it worked every time.

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Hi Darryl

> i thought that might be the only way to do this...

> so i've done all that, but for some reason my Startup Form wont hide when
i
> use the command

> Me.Visible = False

> Any Ideas??

> Thanks

> Jado



Sun, 15 May 2005 22:32:42 GMT  
 VBA - Autoexec Macro Replacement??
Hi Van

Weird!

i've created a new unbound form.  i haven't changed any default settings
form the form.  in the OnLoad Event i have this...

Me.Visible = False
msgbox "Do Autoexec Stuff"

i have changed some options on the Startup Properties screen but thats it!

i'll try it in another untouched db to see if that the problem!

if you've any other ideas, please post!

Thanks

Jado



Mon, 16 May 2005 00:18:09 GMT  
 VBA - Autoexec Macro Replacement??
Hi Van

Well...

when you said it worked for you, how were you activating the form??

if i open my form in design view, then click the view form button on the
form view bar, the code seems to work fine!!

but if i save my form, close it , then open it by double clicking ing the
database window...i get my message box, then the form opens in full view???

same thing if i start my form from the startup properties screen!!
is this normal??

could you test these and let me know if you get the same!

Thanks

Jado



Mon, 16 May 2005 00:36:27 GMT  
 VBA - Autoexec Macro Replacement??
See comments in-line.

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Hi Van

> Well...

> when you said it worked for you, how were you activating the form??

> if i open my form in design view, then click the view form button on the
> form view bar, the code seems to work fine!!

That's how I tested.

Quote:

> but if i save my form, close it , then open it by double clicking ing the
> database window...i get my message box, then the form opens in full

view???

True.  It won't work this way.

Quote:

> same thing if i start my form from the startup properties screen!!
> is this normal??

Doesn't work this way either.

You need to use the AutoExec macro (tested in A2K) with the macro action to
open the Form in "Hidden" mode rather than the StartUp Form in the Options
...



Mon, 16 May 2005 20:11:53 GMT  
 VBA - Autoexec Macro Replacement??
Thanks Van!

looks like i'll need to use the Autoexec macro after all..

so just to clarify...

you don't know of a code equivilent for the Autoexec macro...

i was hoping there would be something like:-

WithEvents Application.Initialize
' Do Autoexec Stuff
'---------------------------

i think i'll be able to achieve results even with the macro as long as i use

AllowBypassKey = False to disable opening the DB whilst holding ShiftKey
and hide the DB Window and built-in Meny Bars

Thanks

Jado



Mon, 16 May 2005 22:16:34 GMT  
 VBA - Autoexec Macro Replacement??
Try this, it seems to work in my quick test:  put your startup code in
the Open event of your startup form, and also in that event set the
event procedure's Cancel argument to True to cancel the opening of the
form.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> Thanks Van!

> looks like i'll need to use the Autoexec macro after all..

> so just to clarify...

> you don't know of a code equivilent for the Autoexec macro...

> i was hoping there would be something like:-

> WithEvents Application.Initialize
> ' Do Autoexec Stuff
> '---------------------------

> i think i'll be able to achieve results even with the macro as long
as i use

> AllowBypassKey = False to disable opening the DB whilst holding
ShiftKey
> and hide the DB Window and built-in Meny Bars

> Thanks

> Jado



Tue, 17 May 2005 01:16:17 GMT  
 VBA - Autoexec Macro Replacement??
Very neat trick, Dirk.

(provided that you don't need to keep the Form open & hidden)

Thanks
Van T. Dinh
MVP (Access)


Quote:
> Try this, it seems to work in my quick test:  put your startup code in
> the Open event of your startup form, and also in that event set the
> event procedure's Cancel argument to True to cancel the opening of the
> form.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



Wed, 18 May 2005 00:38:22 GMT  
 VBA - Autoexec Macro Replacement??
See Dirk's post if you only want to run some code and don't actually need to
keep the Form open & hidden.

Are you aware that you only have to disable the AllowBypassKey ONCE and it
will stay disabled until you enable it again?

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Thanks Van!

> looks like i'll need to use the Autoexec macro after all..

> so just to clarify...

> you don't know of a code equivilent for the Autoexec macro...

> i was hoping there would be something like:-

> WithEvents Application.Initialize
> ' Do Autoexec Stuff
> '---------------------------

> i think i'll be able to achieve results even with the macro as long as i
use

> AllowBypassKey = False to disable opening the DB whilst holding ShiftKey
> and hide the DB Window and built-in Meny Bars

> Thanks

> Jado



Wed, 18 May 2005 00:41:58 GMT  
 VBA - Autoexec Macro Replacement??
Thanks Dirk!

Thats just what i was after!

Jado

Quote:
> Try this, it seems to work in my quick test:  put your startup code in
> the Open event of your startup form, and also in that event set the
> event procedure's Cancel argument to True to cancel the opening of the
> form.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > Thanks Van!

> > looks like i'll need to use the Autoexec macro after all..

> > so just to clarify...

> > you don't know of a code equivilent for the Autoexec macro...

> > i was hoping there would be something like:-

> > WithEvents Application.Initialize
> > ' Do Autoexec Stuff
> > '---------------------------

> > i think i'll be able to achieve results even with the macro as long
> as i use

> > AllowBypassKey = False to disable opening the DB whilst holding
> ShiftKey
> > and hide the DB Window and built-in Meny Bars

> > Thanks

> > Jado



Wed, 18 May 2005 01:55:20 GMT  
 VBA - Autoexec Macro Replacement??
yes thats great!

the only reason i needed the form was to run code to replace the autoexec
macro!

Thanks for all the help !
    we managed to find a solution after all!! :)
i'll keep you posted if there's any hidden problems.

have a good weekend!
Jado



Wed, 18 May 2005 02:02:08 GMT  
 VBA - Autoexec Macro Replacement??
Hi Van , Dirk!

Looks like this may cause a problem after all!!

if i set  Cancel  = True

this is what happens....

code in startup form now runs ok, and form is hidden or closed (whatever
"Cancel = True" does!).  The last thing the code in this form does is to
open a user input form to start using the db.  All ok so far....

The user input form has a exit db routine in it's OnUnload Event...

When i close the form to activate this Event....Nothing happens!!  The form
closes but the Event doesn't run??

Any Idea's ??

"This topic is now just out of interest as i have found an alternative
workaround!"

it would still be nice to follow it thought as it may result in a cleaner
solution to my workaround!

my workaround is to use 2 startup forms.  The first simply opens the second
in a hidden state then closes it's self.  The second form runs all the
autoexec stuff!

Thanks

Jado



Fri, 20 May 2005 19:49:07 GMT  
 
 [ 19 post ]  Go to page: [1] [2]

 Relevant Pages 

1. VBA - Disable Autoexec macro

2. AutoExec Macro to Run VBA Code.

3. Using a VBA Macro to copy a VBA Macro

4. AutoExec Macro Help!!!!!!

5. Automation Problem -- Suppressing AutoExec Macros And Startup Forms

6. Automation Problem -- Suppressing AutoExec Macros And Startup Forms

7. Automation Problem -- Suppressing AutoExec Macros And Startup Forms

8. Automation Problem -- Suppressing AutoExec Macros And Startup Forms

9. Automation Problem -- AutoExec Macros and Startup Forms

10. Access97: AutoExec macro fails following broken references

11. Autoexec macro in Acces 2

12. Autoexec macro disable key

 

 
Powered by phpBB® Forum Software