Calling access with parameters

  • Thread starter Thread starter rwboyden via AccessMonster.com
  • Start date Start date
R

rwboyden via AccessMonster.com

I need to call an access application from within another VB or access
application and pass several parameters to the called application. (1) How do
I call the access application with parameters? and (2) How do I find and
extract those parameters for use within the called application? I'm
reasonably conversant with VBA. Can this be done (Access 2003)?

Many thanks for any help
 
You can pass parameters by using the /cmd switch when opening the database.
This specifies that what follows on the command line is the value that will
be returned by the Command function. This option must be the last option on
the command line. You can use a semicolon (;) as an alternative to /cmd. To
see what was passed, simply refer to Command in your code.

Note that when opening the database, you must specify the Access executable:
you can't just start the mdb file:

"C:\Program Files\...\msaccess.exe" "C:\Folder\File.mdb" /cmd What I Want To
Pass
 
rwboyden said:
I need to call an access application from within another VB or access
application and pass several parameters to the called application. (1) How do
I call the access application with parameters? and (2) How do I find and
extract those parameters for use within the called application? I'm
reasonably conversant with VBA. Can this be done (Access 2003)?


The Command function can be used to return what was
specified in the /cmd option.

Check VBA Help for Startup command-line options.
 
Douglas said:
You can pass parameters by using the /cmd switch when opening the database.
This specifies that what follows on the command line is the value that will
be returned by the Command function. This option must be the last option on
the command line. You can use a semicolon (;) as an alternative to /cmd. To
see what was passed, simply refer to Command in your code.

Note that when opening the database, you must specify the Access executable:
you can't just start the mdb file:

"C:\Program Files\...\msaccess.exe" "C:\Folder\File.mdb" /cmd What I Want To
Pass

Thanks. Using Command to access the passed parqameters works fine.

The code above works as a call from Start - Run and may work as a Shell call
from a vb program. Using Shell from Access seems to require the following
syntax:

RetVal = Shell("C:\Program Files\Microsoft Office\Office11\msaccess.exe
_
C:\McWin\Backup.mdb /cmd 'Parameters'")

This displays the Open/Cancel box and when opened, displays the Access icon
on the task line but I then have to click that icon to actually open the
project. The command line doesn't seem to want to accept the window spec (0,
1, 2,) associated with Shell calls from Access. Any thoughts? ... and is
there any way to bypass the Open/Cancel box and simply open the application?


Again, the help is very much appreciated.

Bob Boyden
 
Back
Top