Microsoft Access is a personal database management system (DBMS). While the database features are not as robust as an enterprise level DBMS, Access has the benefit of being able to encapsulate all the elements of application creation in one system. Access supports the creation of tables, custom queries, user interface forms, reports and code modules. Code modules are written in Visual Basic for Applications (VBA) using the Microsoft Visual Basic Editor. Modules can be either classes linked to specific forms or reports, or they can be standard modules. Standard modules contain functions that can be called from anywhere within your database.
- Skill level:
- Moderately Easy
Other People Are Reading
Click on the "Create" ribbon, then click on the drop-down arrow in the "Other" section and select "Module." This will create a new standard module for VBA code in the Microsoft Visual Basic Editor.
Click on the drop-down arrow in the "Other" section and select "Class Module." This will create a new class module for you.
Select the "Blank Report" button from the "Create" ribbon. Click the drop-down under the "View" button and select "Design." Click on the "View Code" button under "Tools" on the "Design" ribbon to open the class module associated with your report.
Select the "Form" button from the "Create" ribbon. Click the drop-down under the "View" button and select "Design." Select "View Code" under "Tools" on the "Design" ribbon to open the VBA editor for the class module associated with your form.
Select the "Database Tools" ribbon and click on the "Visual Basic" button under "Macros" to open the Microsoft Visual Basic Editor without creating a new module.
Click on the "Insert" menu in the editor and then select "Module" to create a new blank module. You can do the same for a new class module.
Creating and Opening Modules
Right-click on the desired module in the "Project Viewer" window, then select "Remove Module." Select "No" if prompted to export your module. This will delete the selected module.
Convert a macro to a VBA module by clicking on the "Convert Macros to Visual Basic" button on the "Database Tools" ribbon. Click "Convert" in the conversion window to complete the process.
Attach a function from a module to an event by opening your report or form in "Design" view, selecting a control, clicking on the "Event" tab in the "Property" window and typing the name of your function, with an equals sign in front of it and parentheses after it, into the desired event.
Compile your code and verify its syntax by selecting "Compile" from the "Debug" menu in the Visual Basic Editor.
Interacting With Modules
Tips and warnings
- Macros are being phased out in Microsoft Access 2007, so it is a best practice to convert them to VBA.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for