Programming MS Access Applications

Improve Functionality with Macros and Visual Basic for Applications

© Harry P. Schlanger

Visual Basic and Macros, Harry P. Schlanger

An industry application written in Access 2007 is presented for inspection to learn how applications can be made more professional, using macros and VBA programming.

Access 2007 readers knowledgeable in creating applications with wizards and macros can easily learn how to make their applications more professional using the power of VBA programming.

Unlike programming tutorials, the starting point here is to present a full-fledged application that was created for a real organization – a school, by the author. The application is offered for analysis and "reverse-engineering" to inspect the code and learn how code can make the application perform in superior ways that wizards cannot offer.

This new coding knowledge is transferable to any other Microsoft VBA application, such as Word and Excel, etc. Readers without at least a rudimentary knowledge of Visual Basic should first consult a good Access VBA programming book before proceeding.

Building the School Application

The school application is a simple interim reporting system for teachers and can be downloaded. On opening of the database file, the security feature has a button “Options…” that should be clicked, then the “Enable Contents” checkbox should be checked (see Figure 1). The Application was built up from scratch in the following manner:

The database has a pre-loaded list of students, subjects, and teachers. It opens with a main data entry form (Figure 2) , ready for teachers to enter the students’ performance. A Help button explains the main functionality of the application. Another button "Report Preview ~ Students for this Subject" opens the interim report, which can then be printed.

Initiating the Data Entry Form

To initiate data into the data grid, the user needs to click on the subject dropdown and make a selection, say, “games programming”. This loads the data for this subject into the form and students may then be viewed by navigating records. A list of students is also loaded in the student dropdown and allows quick access to records.

Inspecting Macros and VBA Code

To find the code behind each form (which includes macros written in code as DoCmd), one should follow these steps:

An industry application written in Access 2007 by the author using VBA is presented for studying the manner in which code enhances the functionality of applications, making them more professional and user-friendly. Snippets of code and the skills learned are often transferrable across to other VBA applications, such as in Excel, Word, etc.


The copyright of the article Programming MS Access Applications in Database Programming is owned by Harry P. Schlanger. Permission to republish Programming MS Access Applications must be granted by the author in writing.


Figure 1. How to Enable Content, Harry P. Schlanger
Figure 2. Main Data Entry Form, Harry P. Schlanger
Figure 3. Code to Make the Student  Dropdown Work, Harry P. Schlanger
Visual Basic and Macros, Harry P. Schlanger
 


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo