The Code window is found to the right of the Project Explorer in Microsoft Access. It displays the VBA code for the object currently highlighted in the Project Explorer.
If the Code window is not visible when you open the Microsoft Visual Basic window, you can make it visible by selecting Code under the View menu.
In the example below, the VBA code is displayed for the module called Module1.
Good programming practice is to add a “Option Explicit” in between the ‘Option Compare Database’ line and the function definition.
The “Option Explicit” option forces you to declare all variables. If you use a variable that has not been declared then this would result in an error when you run the macro. This is a good way to determine if you made a typographical error on any variable names.
When coding a new application, don’t start from scratch! Leverage our Help4Access Solution Building Blocks™ to jump-start your custom Microsoft Access database application.