Run Module Code in autoexec macro

JeffAccess

Registered User.
Local time
Today, 05:45
Joined
Aug 26, 2013
Messages
21
Hi. I hope someone can help me here, I really searched and just can't find an answer to this.
I am using Access 2007 and I created a module and put this code in: (This is to hide everything on top)
Private Sub Lockdown()
DoCmd.ShowToolbar "Ribbon", actoolbarno
DoCmd.ShowToolbar "Menu Bar", actoolbarno
End Sub

Now, if I run the code, it works 100%. So I created an autoexec macro.
In the design view for the autoexec macro, I put in OpenModule. Doesnt' work because when I open the database, it just opens the module and not run the darn code. :banghead::banghead::banghead:
So I decided to put "Lock" in the procedure name. And when I open the database, it works!!!! BUT, BUT, BUT :banghead:the module window opens and complains "The programme startup can't find the procedure "lock"." I then click on OK and then obviously all macros are stopped.:confused::confused::confused:

I would really appreciate help on this. :)Thanks in Advance.
 
You want RunCode, not OpenModule. Also the code may need to be a public function, not sub (certainly should be public).
 
You want RunCode, not OpenModule. Also the code may need to be a public function, not sub (certainly should be public).

Hi PBaldy
I tried what you said and.......Problem sorted. I tried the RunCode, but was empty when I tried to add, then I saw you said Function, so I changed it to Function and now it works perfect!!!
Thanks alot!
 
Happy to help and welcome to the site by the way!
 

Users who are viewing this thread

Back
Top Bottom