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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a module on start up

Status
Not open for further replies.

longhair

MIS
Feb 7, 2001
889
US
Hi All,

Hope someone has a good suggestion or code example.
The brief story:
I have a database that needs to be updated from numerous other ones at month end. I have created a module that runs all of the append / delete queries and renames / deletes temporary tables. The code works fine from within VB.
What I would like to do is to automate it even more. Depending on the command line argument that I use would like to call to my module. The current code that I have for this is:
Function CheckCommandLine()
If Command = "update" Then
DoCmd.OpenModule "ModuleName"

Else
Exit Function
End If
End Function

All this does if open the DB, it does not run "ModuleName".
I have tried Run, RunCode and a couple of others to no avail. Using Autoexec macro is out of the question because it only needs to be run at certain times by certain people.

Any ideas whould be greatly appreciated.

Regards
 
DoCmd.OpenModule "ModuleName"

won't work. If your function is called runMe then simply put:

Function CheckCommandLine()
If Command = "update" Then
runMe
Else
Exit Function
End If
End Function

Nick
 
Thanks for the idea Nick, but no such luck. Still won't run the module. Any other suggestions?

Regards
 
Why not create an autoexec. The autoexec could then run this function CheckCommandLine.

Nick
 
Autoexec is already used. I could probably do all my work in a macro but feel safer doing it in code (less of a chance of someone accidentally running it)

Regards
 
Do you have a startup form that always opens up when the db is opened?
 
Yes. But I'm thinking of approaching from another direction now. I'll keep a copy of the DB's local, change the autoexec to call to my module then copy the tables to the active DB on the network.

Regards
 
Yeah, similar to what I was thinking. I thought you could just add an extra bit to the autoexec macro calling your function.

Nick
 
Hi!

If you want your module to only run on command then put an Update button on your main form and go to the events tab on the property page. In the On Click event type in the name of the function and it will run whenever the button is clicked.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top