Runtime Parameters in Access

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.
 
T

Tom van Stiphout

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.
 
B

Bill

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
 
T

Tom van Stiphout

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.
 
B

Bill

Okay, thanks. I'll think about how to accomplish
this without causing all kinds of updates in the field.
Bill
 
K

Krzysztof Pozorek [MVP]

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.
(...)
 
B

Bill

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
 
K

Krzysztof Pozorek [MVP]

(...)
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
 
K

Krzysztof Pozorek [MVP]

(...)
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
 
B

Bill

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()
 
K

Krzysztof Pozorek [MVP]

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
 
B

Bill

Okay, thank you.
Bill


Krzysztof Pozorek said:
;-)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top