ACC: How to Find a Record in a Form Using Access BasicLast reviewed: May 14, 1997Article ID: Q114556 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article describes a method that you can use to find a record in a form using the form's recordset and a bookmark. This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x, or the "Building Applications" manual in version 2.0.
MORE INFORMATIONThe Microsoft Access "User's Guide" demonstrates a method using the FindRecord macro action that you can use to find records in a form by selecting a key value from a list. (See the Microsoft Access "User's Guide," version 1.0, pages 547-548, or version 1.1, pages 551-552, or version 2.0, pages 651-652.) The method described in the User's Guide is limited in the following ways:
NOTE: In the following example, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscores from the end of the line when re-creating this example.
The following are examples of valid SQL WHERE clauses:
"[Customer ID] = 3" "[Customer ID] = " & [Find Customer]If the field is a text field, the WHERE clause may look like the following examples:
"[Customer ID] = '3'" "[Customer ID] = '" & [Find Customer] & "'"NOTE: You can use single or double quotation marks to delimit text values. The following examples are functionally identical to the two examples above:
"[Customer ID] = ""3""" "[Customer ID] = """ & [Find Customer] & """"The SQL WHERE clause to find a record for a particular customer on a given date might look like the following examples:
"[Customer ID] = 3 AND [Order Date] = #1/1/94#" "[Customer ID] = " & [Find Customer] & " AND [Order Date] = #" &_ [Find Order Date] & "#" Using the FindRecord_RS FunctionMicrosoft Access version 1.x: The Suppliers form in the sample database NWIND.MDB has a combo box called Select Company To Find that lists available suppliers. When you select a supplier, the Find Company macro is run to find the supplier matching the selection using the FindRecord action. The following steps demonstrate how to use the FindRecord_RS() method instead of the Find Company macro:
Microsoft Access version 2.0: The Products And Suppliers form in the sample database NWIND.MDB has a combo box called Select Product To Find that lists the available products. When you select a product, the Product Pick List.Find Product macro is run to find the product record matching the selection using the FindRecord macro action. The following example demonstrates how to use the FindRecord_RS() method instead of the Product Pick List.Find Product macro:
REFERENCESMicrosoft Access "User's Guide," version 1.0, Chapter 22, "Using Macros with Forms," pages 547-548 Microsoft Access "User's Guide," version 1.1, Chapter 22, "Using Macros with Forms," pages 551-552 Microsoft Access "User's Guide," version 2.0, Chapter 25, "Using Macros with Forms," pages 651-652 |
Keywords : FmsEvnt kbusage
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |