Private | Public
Use the Private and Public keywords to declare variables. This can be done at the module level only. At the module level, the keyword Private replaces keyword Dim. The old keyword Global is completely replaced by Public.
VBA Naming Conventions
Refer to Appendix C for Leszynski Naming conventions.
Declaring Functions
Procedures that return a value (functions) can be delcared and typed just like variables with the form:
Public Function MyFunction(intArg As Integer) As Long
<stuff>
End Function
Passing by Value or by Reference
By default, parameters are passed to functions by reference.
Optional Function Arguments
VBA's use of optional function arguments take the form:
Public Function MyFunction(intArg As Integer, _
Optional varOpt as Variant) As Long
<stuff>
End Function
Optional parameters are always of type variant and are always last in the argument list.
Parameterized Arrays
Parameterized Arrays allow functions to take in any number of values and have the form:
Public Function MyFunction(ParamArray varMyArray() _
as Varaint) As Long
<stuff>
End Function
The For Each...Next Structure
The For Each...Next structure can be used to iterate over the members of a collection. This includes moving through standard Access object collections including controls and forms.
References
Use the References command in the Tools menu to add other object libraries to VBA running under Access. This command is available when viewing code. One great use of this feature is to add the RDO object library to Access, which will allow DSN-less connections to ODBC data sources.
Named Function Parameters
Specify named parameters when function arguments must be listed out of order. This has the form:
ObjectName.MethodName Parameter:=expression, ParameterN: expression