Background
Total Access Analyzer analyzes your entire Microsoft Access database to identify where all the objects are used:
- Access database objects: tables, queries, forms, reports, macros, etc.
- VBA code: modules, classes, procedures, variables, constants, enums, types, etc.
From that, we discover unused objects and code. This includes VBA variables defined in modules and classes if you select the Module XREF option.
Visit our page Finding and Deleting Unused Access Objects and VBA Code for more information on all the different types of unused object analysis it performs.
Difference between Unused and Unreferenced Variables
Unused variables are easy to understand. You define a variable (e.g. Dim x as Integer) and never use it. They can be deleted without much thought.
An Unreferenced Variable is a variable that's defined, assigned a value, yet never used. For instance:
Sub Example() Dim x As Integer x = 5 End Sub
x is assigned a value so it's used, but its value is never referenced. Total Access Analyzer flags it as an unreferenced variable since it's not clear why it exists.
What to do with Unreferenced Variables?
The example is trivial since the procedure does nothing and both lines can be deleted.
More commonly, the procedure is more complex and a variable may be assigned multiple times yet never used. Identifying them is helpful to clean up your code but it may indicate a problem that needs to be fixed. So you could:
- Delete the definition of the variable and everywhere it's assigned a value
- Think about why the variable was defined and assigned a value originally, and what was going to behave differently based on its value. Maybe something is missing that the value is supposed to impact.
We hope this powerful identification of Unreferenced Variables helps you improve the VBA code in your Microsoft Access databases and simplifies their maintenance.
Additional Support Resources
Comments
0 comments
Please sign in to leave a comment.