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!

How do you pass parameters when starting an .ADP 1

Status
Not open for further replies.

thromada

MIS
May 10, 2004
30
US
I have an Access 2003 .ADP file that I want to pass a couple parameters to when I start it up. For example "c:\code\accessprog.adp 'fred' '1234 bedrock'". When I run that, I of course first get the security warning because the file is not digitally signed. And I made the startup in Access start the form I want to run. But even after that, I can't figure out what to use to grab any command line arguments. I found the COMMAND function in Access Help, but I'm not sure where to put it our how to use it. Will starting an ADP file from the command line work with arguments even with a form auto-starting? Or is there a better way than using an ADP to run the "application"?
Thanks,
Tom.
 
Hallo,

I don't know about ADPs, but in an MDB you have to include the application and the /cmd switch. You can then refer to the command line options using the Command function.
ie. In the shortcut:
"C:\Program Files\Microsoft Office\Office\msaccess.exe" "c:\My Documents\Database.mdb" /cmd Parameter1 Parameter2
If you do this then the Command function will return "Parameter1 Parameter2" whenever you call it in VBA.

Maybe you can apply this knowledge to ADPs. Please post details of any results you achieve,

- Frink
 
Found the following:
1. The /cmd command line switch works with .ADP's.
2. You must run MSACCESS.EXE with the .adp and then the /cmd switch. You cannot let the O.S. resolve the file association with the .adp. For example:
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\code\accessprog.adp" /cmd "fred,wilma,1234 bedrock" (The quotes are optional around the arguments after the /cmd switch)
3. After Access loads, the arguments can be viewed from Tools|Options|Advanced.
4. The arguments are available using the VBA Class "Interation.Command". For example:
Private Sub Form_Load()
txtCommandLine = Interaction.Command
End Sub
5. If multiple users run the .adp, each user gets their own set of arguments.

Thanks Frink,

Tom.
 
Cheers Tom,

Thanks for letting us know,

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top