ACC97: Unable to Use FindFirst to Retrieve Value w/ ApostropheID: Q170700
|
Moderate: Requires basic macro, coding, and interoperability skills.
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'"
Me.RecordsetClone.FindFirst "[CompanyName] = "&Me![ComboboxNN]
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.
rst.FindFirst "[CompanyName] = ""B's Beverages"""
This behavior is by design.
This section assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.
Private Sub FindFirst_Click()
Dim rst As Recordset
Dim strCriteria As String
Set rst = Me.RecordsetClone
rst.FindFirst "[CompanyName] = 'B''s Beverages'"
If rst.NoMatch Then
MsgBox "No match was found."
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
End Sub
rst.FindFirst "[CompanyName] = ""B's Beverages"""
For more information about using the apostrophe in the FindFirst argument,
please see the following article in the Microsoft Knowledge Base:
Q104823 ACC: Using Find Method to Find a Quotation Mark or
Apostrophe
Keywords : kbcode GnlFnd
Version : 97
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: April 22, 1999