In Access, macro sums are two different programming tools. Macros are automation tools based on simple actions and conditions, while VBA is a more powerful and flexible programming environment that allows you to create complex logic and custom functions.
In Access, there are some limitations to calling variables defined in VBA in macros, because macros and VBA are two separate execution environments. However, there are ways to pass data or achieve some level of interaction between macros and VBA. With the right approach, you can make the global variables created in VBA available in macros and vice versa.
1. Declare and assign values in VBA, and call and change variable values in macros
Method 1: Use the global variable tempvars
Invoke in a macro:
Method 2: Use a custom function.
Invoke in a macro:
2. Set and assign variables (global) in macros, and call and change variable values in VBA
Used in macrossettempvar operationset global variables;
Manipulate the variable of the macro setting in VBA: Usetempvars collection(You can create new variables, call variable values, delete variables, and so on).
Call variable: x=tempvars!variablename
Assignment: tempvars!variablename=newvalue
Create a new temporary variable and set its value: tempvarsadd "variablename",value
Delete a single temporary variable: tempvarsremove "variablename"