Article ID: 199056
Article Last Modified on 12/12/2002
APPLIES TO
- Microsoft Access 2000 Standard Edition
This article was previously published under Q199056
Moderate: Requires basic macro, coding, and interoperability skills.
For a Microsoft Access 2002 version of this article, see
286242.
SYMPTOMS
When you use the
FindFirst method, you receive a No match or a run-time error message.
This behavior occurs when you search for a value that contains an
apostrophe ('). For example:
rst.FindFirst "[CompanyName] = 'B's Beverages'"
This behavior also occurs if you use the
FindFirst method in the
AfterUpdate event procedure of a combo box, and you search for a value that
contains an apostrophe. For example:
Me.RecordsetClone.FindFirst "[CompanyName] = " & Me![ComboboxNN]
CAUSE
Searches for text strings that contain quotation marks (") or apostrophes
(') require special syntax because both characters are used as delimiters
in Visual Basic for Applications.
RESOLUTION
Workaround for Using a Text String
When you are typing your search argument, use double quotation marks in
your search string to find values that contain single quotation marks and
use single quotation marks in your search string to find values that
contain quotation marks. For example, to search for a CompanyName that
includes an apostrophe, replace the single quotation marks around the
CompanyName value with two sets of double quotation marks, as in the
following example:
rst.FindFirst "[CompanyName] = ""B's Beverages"""
Workaround for Using a Combo Box
If you are using a combo box to find values that contain quotation marks
or apostrophes, add the primary key to the combo box and make it the bound
column. Hide the bound column. Then change your criteria so that it
searches in the field that corresponds to the bound column in the combo
box.
REFERENCES
For more information about the BoundColumn property, click Microsoft Access Help on the
Help menu, type Bind a column from a list box, drop-down list box, or combo box in the Office Assistant or
the Answer Wizard, and then click Search to view the topics
returned.
Keywords: kbdta kbprb KB199056