MS Access Modules Tutorial

Written by susan hare
  • Share
  • Tweet
  • Share
  • Pin
  • Email
MS Access Modules Tutorial
The VBA programming language is similar to Visual Basic 6. (ANSI image by DBX60 from Fotolia.com)

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

Instructions

    Creating and Opening Modules

  1. 1

    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.

  2. 2

    Click on the drop-down arrow in the "Other" section and select "Class Module." This will create a new class module for you.

  3. 3

    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.

  4. 4

    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.

  5. 5

    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.

  6. 6

    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.

    Interacting With Modules

  1. 1

    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.

  2. 2

    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.

  3. 3

    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.

  4. 4

    Compile your code and verify its syntax by selecting "Compile" from the "Debug" menu in the Visual Basic Editor.

Tips and warnings

  • Macros are being phased out in Microsoft Access 2007, so it is a best practice to convert them to VBA.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.