Chapter 6. Building Interactive Forms

Chapter 5 covered the basics of using ADO and SQL to work with data sources and showed you how to display the data retrieved from the database on a form. In this chapter, you will explore ways to build interactive forms and to control the operation of those forms programmatically using VBA code. Many of the topics covered in this chapter are illustrated in various examples throughout the book, but some also deserve a separate discussion.

The chapter will cover:

  • Navigating between forms

  • Opening, closing, and hiding forms

  • Choosing the right type of control to use for data

  • Populating controls

  • Displaying messages to the user

  • Validating data entered into controls

  • Setting control alignment and tab stops

Form Navigation and Flow

You can control the order and manner in which forms can be opened within your Access applications in various ways. For example, you can design switchboard forms that allow the user to select which form to open. Another option is to open a main form and allow a user to open separate forms from the main form. The style of navigation you choose depends on the type of system and the manner in which users will interact with the various forms.

During the design phase, you should consider the flow of forms and how users will navigate from one form to the next. It is very simple to control how forms are displayed. The following is an example that illustrates how to open, hide, minimize, and close forms.

'open a form DoCmd.OpenForm "FormName" 'close ...

Get Beginning Access 2003 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.