Runtime Parameters in Access

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

How do I pass a parameter to an application
at runtime? Specifically, a parameter that
AutoExec can examine in order to determine
which of two functions it should run.

I've tried to solve the problem by using the
/x MyMacroName, but AutoExec seems to
override that.
 
On Mon, 31 Dec 2007 18:13:02 -0800, "Bill" <[email protected]>
wrote:

AutoExec runs before MyMacroName. So it's up to you to structure your
code such that this works for your purposes.

-Tom.
 
Tom,
Is there a way to pass an argument to AutoExec
from the invoking command line such that the
AutoExec could run one of two different functions?
Bill
 
No.

I might consider using AutoExec for general initializations, and
MyMacroName for more specialized processing.

Really, it's just a matter of getting your mind around the fact that
you have to structure your code such that both conditions work.

-Tom.
 
Okay, thanks. I'll think about how to accomplish
this without causing all kinds of updates in the field.
Bill
 
Actually, why not? You may accomplish it in this way:

1. Pass your parameter:
"C:\...\MSACCESS.EXE" "C:\Db1.mdb" /cmd Par1

2. Build Autoexec:
Condition Action
---------- ----------
Command()="Par1" Macro1
.... StopMacro
Macro2

3. That's all ;-)

You can alternatively set start form and solve in code this:
Private Sub Form_Load()
If Command() = "Par1" Then
'Action 1
Else
'Action 2
End If
End Sub


Kris, MVP Poland
www.access.vis.pl


(...)
No.

I might consider using AutoExec for general initializations, and
MyMacroName for more specialized processing.

Really, it's just a matter of getting your mind around the fact that
you have to structure your code such that both conditions work.

-Tom.
(...)
 
I've coded the following macro and I don't see why it does not
function properly. Even as I single-step the macro it doesn't run
the code specified in the Function Name field corresponding to
the condition action.

Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
StopMacro
Runcode run fx ScrRes()

The intent is to run DBDistribution() if the invoking line command
includes the expression /cmd DBDist or ScrRes() if the expression
is missing.

Bill
 
(...)
Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
StopMacro
Runcode run fx ScrRes()

The intent is to run DBDistribution() if the invoking line command
includes the expression /cmd DBDist or ScrRes() if the expression
is missing.

You forgot adding three dots in Conditions column.

Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
... StopMacro
Runcode run fx ScrRes()

Above ... is important :-)



Kris, MVP Poland
www.access.vis.pl
 
(...)
Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
StopMacro
Runcode run fx ScrRes()

The intent is to run DBDistribution() if the invoking line command
includes the expression /cmd DBDist or ScrRes() if the expression
is missing.

You forgot adding three dots in Conditions column.

Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
... StopMacro
Runcode run fx ScrRes()

Above ... is important :-) It marks the continuation of previous condition.



Kris, MVP Poland
www.access.vis.pl
 
Wouldn't that mean I need ... on the 3rd line as well?

Like:

Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
... StopMacro
... Runcode run fx ScrRes()
 
Wouldn't that mean I need ... on the 3rd line as well?

Like:

Condition Action
------------------------ ------------
Command() = "DBDist" Runcode run fx DBDistribution()
... StopMacro
... Runcode run fx ScrRes()



;-)

Look on passed by me example attentively. Only_one_line contains dot.

Command() = "DBDist" Runcode run fx DBDistribution()
... StopMacro
Runcode run fx ScrRes()



Kris, MVP Poland
www.access.vis.pl
 
Back
Top