Auto Open Procedures In Access !

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
9,729
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I would like to run a procedure upon opening a DB file ( Not a DB object). Something like the Workbook_Open procedures in an Excel workbook.How do I do that ?

Regards.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This is straight from Access Help.

Carry out an action when my database first opens
You can use a special macro named AutoExec to carry out an action or series of actions when your database first opens. When you open a database, Microsoft Access looks for a macro with this name and, if it finds one, runs it automatically.

Create a macro containing the actions you want to run when you open the database.
How?

Save the macro with the name AutoExec.
The next time you open the database, Access runs this macro automatically.

Notes

If you don't want to run the AutoExec macro when you open the database, hold down the SHIFT key when the database opens.


You can also control how a database or application starts by setting options in the Startup dialog box (Tools menu). For more information, click
 
Upvote 0
Thaks Norie,

I am so carried away with Excel ..I thought it was called Auto_Open like in Excel Not Autoexec.!

I still have an issue however: I have an AutoExec Macro with two Actions :

RunCode and OpenForm.

1-The RunCode action is supposed to run the Hide_App procedure in Module1. This proc is basically meant to hide the Access application. Below is the code :

Code:
Option Compare Database

Public Sub Hide_App()
    Beep
    MsgBox "Access will disappear!"
    Application.Visible = False
End Sub

Public Function Call_Hide_App()
    Call Hide_App
End Function


2-The OpenForm action is supposed to show a form called frmWelcome after the application is hidden.



When I open the DB file and the AutoExec macro fires, I get an error at the Application.Visible = False code line. The error message I get is: "You entered an expression that has an invalid reference to the property Visible "

Note that I had to use VBA code to hide the Application because I couldn't find an Action to do that in the Macro builder.

I also thought of trigering this Hide_App procedure upon showing the welcome form but I couldn't find the matching event property in the form's properties box.

Any ideas why I get this error or how I could solve this problem ?

Regards.
 
Upvote 0
dont use the application.visible = false as the line of coda
make it the application name.visible = false
so just say its called hello
the code would be hello.visible = false
try that
 
Upvote 0
tails said:
dont use the application.visible = false as the line of coda
make it the application name.visible = false
so just say its called hello
the code would be hello.visible = false
try that

Thanks tails but sorry I don't get it. What do you mean by adding hello..?

Regards.
 
Upvote 0
Hi Jaafar
There is a way of doing this with a macro, as follows :

Macro Autoexec
RunCommand -> WindowHide
OpenForm -> frmWelcome
StopMacro

HTH, Andrew. :)
 
Upvote 0
andrew93 said:
Hi Jaafar
There is a way of doing this with a macro, as follows :

Macro Autoexec
RunCommand -> WindowHide
OpenForm -> frmWelcome
StopMacro

HTH, Andrew. :)

Thanks Andrew but that only hides the DB window not the Application window.

Regards.
 
Upvote 0
Re-reading your post, are you wanting to show a form after hiding the entire MS Access window? I didn't think this was possible if the form was part of the application / database - although I am happy to be proved wrong.
Andrew :)
 
Upvote 0
andrew93 said:
Re-reading your post, are you wanting to show a form after hiding the entire MS Access window? I didn't think this was possible if the form was part of the application / database - although I am happy to be proved wrong.
Andrew :)

Andrew, it surely is possible & very easy to do that in Excel so I thought it would be the same with Access being another Office application.
I'll keep trying to see if I can come up with anything.

Regards.
 
Upvote 0
well with the database name, what is the name of the application... not the database itself, but the application name, eg. when you saved it what did u call it when you first open access to create it.
 
Upvote 0

Forum statistics

Threads
1,221,875
Messages
6,162,563
Members
451,775
Latest member
Aiden Jenner

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top