PawCom Application Note 104: Automating PawCom with a command line switch ========================================================================= 4/9/04 The MS Access front end for PawCom can accept a command line switch that you can use to automate any process you wish. For example, a default switch is included that will run the refresh process then stop the application. This is handy if you want to schedule an automatic update at off hours. Your can invoke the command line switch from a desktop icon or from a batch file that you can run with the Windows scheduler. To do this you need to build an appropriate command line. There are three things you need to specify: the location of MS Access on your system, the name of the mdb you want to run, and the name of the switch you want to use. To find the location of MS Access, search your system for the file MSACCESS.EXE. Lets suppose you find it in the following location: c:\Program Files\Microsoft Office2000\Office\ and lets suppose you want to run PawCom253-2k.mdb located in the folder c:\pawcom253\ and pass it the command line switch "myswitch". Then the command line you would use is "c:\Program Files\Microsoft Office2000\Office\MSAccess.exe" c:\pawcom253\pawcom253-2k.mdb /cmd "myswitch" Note that quotes are required around the first part of this line because the path has imbedded spaces. The quotes tell the parser that the first part is all one entity. If the location of the mdb you want to run also contains spaces, then you should put quotes around this also. The quotes around the name of your switch are always required. You can easily test your command line by creating a desktop shortcut whose target is the command line. Try setting up a shortcut that starts PawCom on your system. Now lets see what this does. When PawCom starts up the Form_Open event of the main menu does some initialization and then calls the routine CheckCommandLine(). This routine is located in the module Support Functions and the original code looks like this: Public Function CheckCommandLine() Dim Status As Integer If Command = "Refresh" Then Status = mwReadAll() DoCmd.Quit End If End Function Command is a global variable that gets passed to an Access application on startup and contains the value of the switch you specified in quotes after /cmd in the command line. The routine above checks for the switch "Refresh". If it is present it runs the routine mwReadAll, which is equivalent to selecting Refresh from the PawCom menu bar. After the refresh is completed DoCmd.Quit shuts the application down. Try modifying this routine to include your own processing. For example, Public Function CheckCommandLine() Dim Status As Integer If Command = "Refresh" Then Status = mwReadAll() DoCmd.Quit ElseIf Command = "myswitch" Then MsgBox "My switch was specified." End If End Function