Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modules

Status
Not open for further replies.

RabSwinney

Technical User
Aug 21, 2002
25
0
0
FI
Hi There, how can I get a module to run automaticaly, can you have a look at my code and tell me what I need at the start. I will use the module with the Autexec Macro.

Sub run()


DoCmd.OpenReport "Rpt_GB01 Ex Pefc and Fsc", acViewPreview, "", "", acNormal
DoCmd.SetWarnings (False)
DoCmd.OutputTo acReport, "Rpt_GB01 Ex Pefc and Fsc", "SnapshotFormat(*.snp)", "\\Fftilsmb3002\production\Intranet\Planning\Non_Utilised_RawMaterial\Rpt_GB01 Ex Pefc and Fsc.snp", False, "", 0
DoCmd.SetWarnings (False)
DoCmd.Close acReport, "Rpt_GB01 Ex Pefc and Fsc"

DoCmd.OpenReport "Rpt_GB02 Ex Pefc and Fsc", acViewPreview, "", "", acNormal
DoCmd.SetWarnings (False)
DoCmd.OutputTo acReport, "Rpt_GB02 Ex Pefc and Fsc", "SnapshotFormat(*.snp)", "\\Fftilsmb3002\production\Intranet\Planning\Non_Utilised_RawMaterial\Rpt_GB02 Ex Pefc and Fsc.snp", False, "", 0
DoCmd.SetWarnings (False)
DoCmd.Close acReport, "Rpt_GB02 Ex Pefc and Fsc"

DoCmd.OpenReport "Rpt_GB03 Ex Pefc anf Fsc", acViewPreview, "", "", acNormal
DoCmd.SetWarnings (False)
DoCmd.OutputTo acReport, "Rpt_GB03 Ex Pefc anf Fsc", "SnapshotFormat(*.snp)", "\\Fftilsmb3002\production\Intranet\Planning\Non_Utilised_RawMaterial\Rpt_GB03 Ex Pefc and Fsc.snp", False, "", 0
DoCmd.SetWarnings (False)
DoCmd.Close acReport, "Rpt_GB03 Ex Pefc anf Fsc"

DoCmd.OpenReport "Rpt_GB11 Ex Pefc anf Fsc", acViewPreview, "", "", acNormal
DoCmd.SetWarnings (False)
DoCmd.OutputTo acReport, "Rpt_GB11 Ex Pefc anf Fsc", "SnapshotFormat(*.snp)", "\\Fftilsmb3002\production\Intranet\Planning\Non_Utilised_RawMaterial\Rpt_GB11 Ex Pefc and Fsc.snp", False, "", 0
DoCmd.SetWarnings (False)
DoCmd.Close acReport, "Rpt_GB11 Ex Pefc anf Fsc"

DoCmd.OpenReport "Rpt_GB12 Ex Pefc anf Fsc", acViewPreview, "", "", acNormal
DoCmd.SetWarnings (False)
DoCmd.OutputTo acReport, "Rpt_GB12 Ex Pefc anf Fsc", "SnapshotFormat(*.snp)", "\\Fftilsmb3002\production\Intranet\Planning\Non_Utilised_RawMaterial\Rpt_GB12 Ex Pefc and Fsc.snp", False, "", 0
DoCmd.SetWarnings (False)
DoCmd.Close acReport, "Rpt_GB12 Ex Pefc anf Fsc"


End Sub
 
I've never tried it (use Sub_Main in VB6), but I think if you use the OpenModule action in the macro (AutoExec)definition along with the module name it will run?
Alternately, you could go to Tools|Startup and select a form to open, add a call to your proc in the Form_Open event, then close the form in code.

Swiped from MS 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.
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).

Hope this helps - good luck!


I have great faith in fools; self-confidence my friends call it.
-Poe
 
Have a look at the help about the RunCode macro action.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top