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

Start Access from the command line and DETECT it. 1

Status
Not open for further replies.

cmmrfrds

Programmer
Feb 13, 2000
4,690
US
Is there an easy way to determine in access if it was started from the command line. My app has all the main processing logic in the AutoExec Marco and I would like to bypass the autoexec if it doesn't start form the command line. [sig][/sig]
 
It can be done
I suppose when you say command line you mean you have an Icon or are you launching it from another application?
To test your command line you can simply create a desktop icon with code similar to this:
"C:\Microsoft Office97\Office\MSACCESS.EXE" "X:\WEB site Brochur Req.mdb" /cmd 123.
Which is the full path to Access and a blank space, then the full path to the database and another blank space then /cmd and a blank space and a parameter that you decide. I used 123 which is the employee ID

I would rename your autoexec macro temporarily.
There are several things that come to mind.
1. when you launch Access, pass a /cmd parameter to it like so: "C:\Microsoft Office97\Office\MSACCESS.EXE" "X:\WEB site Brochur Req.mdb" /cmd 123.
2. I have used this for knowing which employee opened the database.
3. In Access have a Autoexec macro but instead of it launching something it runs a function.
4. So in the Modules TAB create a function first then create the autoexec macro and use the ”run code” option instead of open a form or whatever.
5. Back to your function.
6. Say you pass 1 to it in the command line In your function use

Public Function Test()
Dim x As Variant
x = Command
MsgBox "you passed " & x, vbInformation, "Command line argument"
If x = 1 Then
'do something
Else
'Open a form
DoCmd.OpenForm "Yourform", acNormal
End If

End Function

Save your function and DO NOT PUT ANY SPACES IN IT’S NAME.
Then create a new Autoexec macro that calls the above “Public Function Test()”
Click “Run code”
Then look at the bottom click in the function name and click the 3 dots.
Next double click the Functions folder
You will see “Built in functions and
Click the name of your database
You should see your new function
Double click it
and then save your macro.

Then test you new function using the command line example above
[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
Thanks Doug. So, Access has a keyword &quot;Command&quot; to return the command line argument. Works fine. I implemented it in my AutoExec by checking the &quot;Command&quot; as a condition and then the 3 dots in each line to be executed. This effectively bypasses the processing when I or the user inadvertantly double click on the mdb.

Jerry [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top