Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO Recordset Find Limitation?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00405064
Message ID:
00405199
Views:
22
>Have you tried replacing the single quote with two single quotes?
>
>>The long and short of it is I CANNOT DO AN ADO.RECORDSET.FIND ON AN EXPRESSION WHICH HAS AN EMBEDDED SINGLE QUOTE IN IT.
>>
>>Could someone please show me a workaround or correct me if I'm wrong?
>>
>>Thanks a million!
>>
>>-JT

Thanks Tim, works like a charm!

In order to accomplish this, I coded as follows:

Private Sub cmdFind_Click()
Dim cCompName As String
Dim varBookmark As Variant
cCompName = InputBox("Enter a company name to locate:")
varBookmark = datPrimaryRS.Recordset.Bookmark

' Test to see if there's a single quote in the search expression
' If so, replace it with two single quotes so the find doesn't blow up!
If InStr(1, cCompName, "'") > 0 Then
cCompName = Mid(cCompName, 1, InStr(1, cCompName, "'") - 1) & _
"''" & Mid(cCompName, InStr(1, cCompName, "'") + 1)
End If

datPrimaryRS.Recordset.Find "CompanyName = " & "'" & cCompName & "'", _
0, adSearchForward, adBookmarkFirst
' If not found
If datPrimaryRS.Recordset.EOF Or datPrimaryRS.Recordset.BOF Then
datPrimaryRS.Recordset.Bookmark = varBookmark
MsgBox "Record not found."
End If
End Sub

This VB/ADO stuff is pretty new to me but I'm getting the hang of it. I figure I'd better get up to speed with it if I want to be competitive in the marketplace! Actually, from the looks of things I should probably be learning Java on Linux if I want to continue developing software apps in the the longterm future.

Thanks to all for the help!

-JT
Jeff Trockman, MCP
Previous
Reply
Map
View

Click here to load this message in the networking platform