Microsoft Access 2000: Building Applications with Forms and Reports |
Welcome to Microsoft Access 2000: Building Applications with Forms and Reports, your introduction to designing and creating Microsoft® Access applications. In this book, you’ll find out how to build applications that you and others can use to effectively manage data. In addition, you’ll be introduced to Visual Basic® for Applications (VBA)—the programming language included in Microsoft Access that takes you beyond what you can accomplish by using only the Access interface.
Microsoft Access 2000: Building Applications with Forms and Reports consists of ten chapters:
Chapters 1 through 3 show you how to tie database objects together into a coherent system and introduces VBA, the programming language used in Access. Examples in these chapters are based on the Orders sample application. You can download the Orders sample application and associated Help files from the Microsoft Developer Network (MSDN™) Online Web site.
Chapters 4 and 5 describe the objects and collections you can work with in Visual Basic and the events you can respond to. For more information about how to use the Visual Basic debugging tools to test and debug your Visual Basic code, and how to respond to errors that occur while your code is running, see Chapter 8, "Error Handling and Debugging," in the Microsoft Office 2000/Visual Basic Programmer's Guide (Microsoft Press, 1999). You can also find this guide in the Office Developer Documentation section of the Microsoft Developer Network (MSDN) Online Library.
Chapters 6 through 8 show you how to accomplish complex data management tasks in your application, including manipulating sets of records in code, and how to optimize, secure, and deliver your application to users. For information about developing an application for multiple users, communicating with other applications such as Microsoft Excel or Microsoft Word, and using library databases and dynamic-link libraries, see Chapter 16, "Multiuser Database Solutions," Chapter 10, "The Windows API and Other Dynamic-Link Libraries," and Chapter 11, "Add-ins, Templates, Wizards, and Libraries," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
Chapters 9 and 10 explore powerful features that address special development needs such as using ActiveX® controls and developing applications for the Internet and the World Wide Web. For information about add-ins, wizards, and libraries, see Chapter 11, "Add-ins, Templates, Wizards, and Libraries," in the Microsoft Office 2000/Visual Basic Programmer's Guide. For information about working with external or client/server data and implementing database replication, see Chapter 16, "Multiuser Database Solutions," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
Note For information about the subjects listed below and about creating the objects that make up an Access database, see the Microsoft Office 2000/Visual Basic Programmer's Guide.
In addition, consult Access Help with questions that arise as you learn Access.
Microsoft Access for Windows® 97 introduced many new features for application development. Microsoft Access 2000 introduces additional new features, as well as enhancements to existing features. The following sections highlight these new features.
See Also For more detailed information about new features in Access, type What's new in the Office Assistant or on the Answer Wizard tab in the Help window, and then click Search.
Note If you have applications that were created with Microsoft Access 97 or earlier, you’ll need to consider several important changes that affect your existing code and database objects. For more information, type converting databases in the Office Assistant or on the Answer Wizard tab in the Help window, and then click Search.
The incorporation of the Microsoft Visual Basic Editor into Access brings the following new and improved professional development tools.
Better Debugging Tools The Immediate window, which can be used to type commands and send information; a Watch window, which you can use to view the value of an expression or a control while your code is running; and a Locals window, which automatically provides information about the variables in your procedures while they are running. The Project Explorer displays a hierarchical list of all projects and the items contained in and referenced by each project. The Properties window lists the design-time properties and their settings for a selected object. For more information, see Chapter 8, "Error Handling and Debugging," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
Microsoft ActiveX® Data Objects (ADO) You can now use ADO to access and manipulate data in a database server through any OLE DB provider. For more information about ADO, see Chapter 14, "Working with the Data Access Components of an Office Solution," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
The following features, available to users and developers alike, provide straightforward solutions to some of the challenges of creating a database application.
Database Wizard When you need a simple application right away, or just want to see sample tables, forms, and reports to help you plan your application, the Database Wizard can create all the pieces of many common applications for you. See Chapter 1, “Creating an Application.”
Startup Options Using the Startup dialog box (Tools menu), you can quickly specify your application’s startup form, title bar text, icon, menu, and toolbar, without changing any initialization settings. You use this same interface to make customization options unavailable to your users when you deliver your completed application. See Chapter 1, “Creating an Application” and Chapter 8, “Delivering Your Application.”
Subdatasheets Use a subdatasheet to view and edit related or joined data in a table, query, or form datasheet, or in a subform. See Chapter 3, “Using Forms to Collect, Filter, and Display Information.”
Toolbars, Menu Bars, and Shortcut Menus Using the new personalized menus from Microsoft Office and the ability to attach hyperlinks to toolbar buttons and menu commands, you can create custom toolbars and menus in your application. See Chapter 1, “Creating an Application.”
Record-level locking Access databases now support record-level locking, in addition to page-level locking. See Chapter 3, “Using Forms to Collect, Filter, and Display Information.”
The following advanced features help make Access more powerful and extensible.
Form Event Improvements A new form event, the Dirty event, help you respond to form changes and data entry. See Chapter 5, “Responding to Events.”
Object Model Improvements For more control over your application and its environment, use the CurrentProject, CurrentData, CodeProject, CodeData, Data Access Page, DefaultWebOptions, WebOptions, File Search, COMAddIns objects, and new methods of the Application object. See Chapter 4, “Working with Objects and Collections.”
Microsoft SQL Server You can now create an Access project that is easy to connect to a Microsoft SQL Server database, or use the Microsoft SQL Server Database Wizard to quickly create a SQL Server database and an Access project at the same time. For more information, see Chapter 16, "Multiuser Database Solutions," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
Data Access Pages A data access page is a web page that you can use to add, edit, view, or manipulate current data in an Access database or a SQL Server database. You can create data access pages that are used to enter or edit data, similar to Access forms. You can also create pages that display grouped records, similar to Access reports. For more information, see Chapter 5, "Working with Office Applications," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
Database Replication Replication commands on the Microsoft Access Tools menu in an Access database or project allow you to create replicas and synchronize them on demand. Jet and Replication objects (JRO) provide methods and properties for developers to use in programmatically replicating and synchronizing databases and projects. For more information about database replication, see Chapter 16, "Multiuser Database Solutions," in the Microsoft Office 2000/Visual Basic Programmer's Guide.
New Internet Features With the new data access page, you can create web pages that you can use to add, edit, view, or manipulate current data in an Access database or a SQL Server database. NetMeeting® provides the ability to collaborate with others in an Access database or project. You can also assign a hyperlink to a toolbar or menu command for easy access to a location on your computer, a network, an intranet, the Internet, or the World Wide Web. See Chapter 10, “Developing Applications for the Internet and the World Wide Web.”
This manual uses the following typographic conventions.
Example of convention | Description |
Sub, If, ChDir, Recordset, Time, FontSize | Words in bold with the initial letter capitalized are language-specific words with special meaning to Visual Basic. These can be functions, statements, objects, methods, properties, operators, or keywords. |
DblClick, TransferText | Names of events and actions appear with the initial letter capitalized. Concatenated names may contain other capital letters. |
expr, path | In syntax, text in italic indicates placeholders for information you supply. |
[color] | In syntax, items inside brackets are optional. |
{While | Until} | In syntax, braces and a vertical bar indicate a mandatory choice between two or more items. You must choose one of the items unless all of the items also are enclosed in brackets. |
|
This font is used for code. |
acViewNormal | Intrinsic constants consist of a word or words that begin with an initial capital letter, preceded by a prefix that indicates which type library they reside in. The prefix “ac” indicates that the constant is a Microsoft Access constant; the prefix “vb” indicates that the constant is a Visual Basic constant; the prefix “db” indicates that the constant is a DAO constant, the prefix “ad” indicates that the constant is an ADO constant. Constants are shown in bold. |
ENTER | Small capital letters are used for the names of keys, such as ENTER and CTRL. The key names correspond to the names on the IBM® Personal Computer keyboard. Other computers may use different names for keys. |
ALT+F1 | A plus sign (+) between key names indicates a combination of keys. For example, ALT+F1 means hold down the ALT key while pressing the F1 key. |
|
The line-continuation character ( _ ) consists of a space and an underscore. It indicates that the code before and after the line-continuation character should appear on one continuous line. |
This manual uses the following guidelines in its Visual Basic code:
Dim intSomeValue As Integer, strTextValue As String
Dim intStartNumber As Integer
' If, Then, and Str are Visual Basic keywords.
If intSomeValue = 0 Then strTextValue = Str(intStartNumber)
Dim dblIncome As Double
Dim strFirstName As String * 30
On Error GoTo ErrorHandler
.
.
.
ErrorHandler:
MsgBox Err.Description
' This is a comment; these two lines
' are ignored when the program is running.
Sub SomeCode()
If intX > 0 Then
intP = intQ
End If
End Sub