PDA

View Full Version : Solved: Using Macro Defined Variables



Imdabaum
06-07-2010, 11:07 AM
I have a macro where I would like to set some temporary variables. I know how to set the variables, but then it doesn't seem to allow me to use these values later on in the macro.

Any pointers?
4 variables: mgr, amt, ext, request
I want all these values set by objects on the subform ie:

SetTempVar--> Name: mgr, Expression: [Forms]![Subform].[Form]![Combo225]
SetTempVar--> Name: amt, Expression: [Forms]![Subform].[Form]![Text100]
SetTempVar--> Name: ext, Expression: [Forms]![Subform].[Form]![Combo210]
SetTempVar--> Name: request, Expression: [Forms]![Subform].[Form]![Combo115]

I later want to use that variable in a macro condition where:
(ReviewYN ="N" AND RequiresReview(mgr, amt, ext, request)) triggers a RunSQL command.

The condition is too long if I bind the parameters to the Form!item.Value.

I am doing it the way I described and it seems to think that I haven't passed any parameters into the function.

Imdabaum
06-07-2010, 11:41 AM
http://blogs.msdn.com/b/clintcovington/archive/2007/02/15/macros-in-access-2007.aspx

There are four new macro actions associated with TempVars:
(1) TempVars![Name]returns the variant value that was stored.
(2) SetTempVars(Name, Expression) allows macros to set a TempVar to a given value.
(3) RemoveTempVars(Name) removes the TempVar from the store.
(4) RemoveAllTempVars empties the TempVars store.

My book and Help all mentioned everything but the TempVars![Name] part. This does the trick. Hope this helps someone else.