Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

SUMMARY

• The event-driven paradigm allows programmers to build applications that respond to actions initiated by the user or system.

• Access VBA includes a number of events that are categorized by the objects they represent.

• Objects are nouns such as a person, place, or thing.

• Objects have properties that describe the object and methods, which perform actions.

• Properties and methods of objects are accessed using the dot operator (period).

• The VBE (Visual Basic Environment) contains a suite of windows, toolbars, and menu items that provide support for text editing, debugging, file management, and help.

• Procedures are containers for VBA code.

• VBA statements are comprised of variables, keywords, operators, and expressions that build a complete instruction to the computer.

• Comment statements are ignored and not processed as a VBA statement by the computer.

• The Forms collection contains all open forms in an Access database.

• The Me keyword refers to the current object or form within the scope of the VBE code module.

• The DoCmd object runs Microsoft Access functionality from VBA code.

• Use the Val function to accurately process numbers retrieved from text boxes.

• Variables are declared using the keyword Dim.

• Variables are pointers to storage locations in memory that contain data.

• All number-based variables are initialized to zero (0), string variables are initialized to empty string (“”), and Boolean variables are initialized to False.

• Constants are useful for declaring and holding data values that will not change during the life of your application.

• The Option Explicit statement forces an explicit declaration before a variable can be used.

• VBA supports order of operations using parentheses.


CHALLENGES

1. Create a simple word processor that allows a user to enter text into a large text box. (Hint: Set the Enter Key Behavior property of a text box to New Line in Field.) The user should be able to change the foreground and background colors of the text box using three command buttons representing three different colors. Also, the user should be able to change the font size of the text box using up to three command buttons representing three different font sizes.

2. Build a simple calculator program with an Access form that allows a user to enter numbers in two separate text boxes. The Access form should have four separate command buttons for adding, subtracting, multiplying, and dividing. Write code in each command button’s Click event to output the result in a label control.

3. Create a discount book program that allows a user to enter an initial book price, a discount rate (e.g., 10% off), and a sales tax percentage. The program should display, in labels, the derived discount price, sales tax amount, and final cost of the book.