Previous Page

CHAPTER  1

Creating an Application

After you become familiar with the Microsoft Access interface and learn how to create tables, queries, forms, and reports, you can make your database easier to use by tying these objects together in an application. This chapter explains what a Microsoft Access application is and presents an overview of the steps required to build one, either with the Database Wizard or on your own. When you finish reading this chapter, you'll be ready to create your first Microsoft Access application.

What Is a Microsoft Access Application?

People use a database to perform data management tasks, such as storing, retrieving, and analyzing data about orders and customers. A Microsoft Access application is made up of the same objects as a Microsoft Access databasetables, queries, forms, reports, macros, and modules. The objects are stored in one or more Microsoft Access database (.mdb) files. What makes an application different from a database is that the objects are tied together into a coherent system. An application organizes related tasks so that the user can focus on the job at hand, not on how the application works or on the program used to develop the application.

The keys to a Microsoft Access application are its objects, their properties, and the events that occur on forms. Here's how it works:

An application consists of objects   Your application is made up of objects that users see and use directly (forms and reports) and supporting objects that control how the forms and reports work (tables, queries, macros, and modules). You build the forms and other objects in their respective Design views.

Objects have properties you can set   You set objects' properties to make them look and behave the way you want. For example, all forms have a DefaultView property that specifies whether a form should appear in Form or Datasheet view. Once you set the property, the form opens automatically in the correct view. By setting properties, you make your objects behave more intelligently.

Forms respond automatically to events   When people use the forms in your application, their actionschanging data in a field, clicking a command button, moving the mouseare recognized by Microsoft Access as events. Microsoft Access responds to these events automatically. For example, when a user changes the data in a text box, Microsoft Access checks to make sure that the data is the correct data type. When a user clicks a command button, Microsoft Access displays the button so it appears pressed in.

You can add your own, custom response to an event   You can use either a macro or an event procedure to add the response you want to an event. An event procedure is a Visual Basic procedure you write that's attached to a form, report, or control; Microsoft Access runs it when a specified event occurs. You specify in the event procedure or macro what you want to take place when the event occurs. For example, you can change object properties, open or close objects, or manipulate data. You use event properties to determine whether Microsoft Access runs a macro or an event procedure in response to an event. For example, to have a macro run in response to a command button's Click event, you set the button's OnClick event property to the name of the macro.

You can extend Visual Basic with external libraries   In addition to writing your own event procedures, you can use Visual Basic to call external procedures in Microsoft Access library databases (MDAs) and in dynamic-link libraries (DLLs). For example, you can enable or disable menu commands by calling functions in the DLLs that are part of Microsoft Windows.

See Also   For more information on external libraries, see Chapter 12, "Using Library Databases and Dynamic-Link Libraries."

The following illustration shows the building blocks of a Microsoft Access application, starting at the top with the elements you work with most frequently.

Where Is My Application's "Brain"?

If you've developed database applications using other products, you may expect to write a Main program in the Visual Basic language that makes your application work. The Main program would be the application's brain; you'd use it to tell the objects how to appear and react, and how to process the data, much as the manager of an office delegates different projects.

With Microsoft Access, the objects manage themselves by responding to events that occur within your application. There is no Main program. For example, suppose you want something to happen when the user clicks a button. You don't need code that checks to see whether the user clicks the button. You attach the code to the button so it's run when the Click event occurs. When the event occurs, Microsoft Access runs your code automatically.

© 1996 Microsoft Corporation. All rights reserved.

Next Page


Casa de Bender