Article ID: 104823
Article Last Modified on 5/6/2003
Function FindaPost1 ()
Dim MyDB As Database, MyDynaset As Dynaset
Set MyDB = CurrentDB()
Set MyDynaset = MyDB.CreateDynaset("Customers")
'Find this company.
MyDynaset.FindFirst "[company name]='Around the Horn'"
If Not MyDynaset.nomatch Then
MsgBox MyDynaset.[company name]
Else
MsgBox "No Match"
End If
MyDynaset.Close
End Function
Function FindaPost2 ()
Dim MyDB As Database, MyDynaset As Dynaset
Set MyDB = CurrentDB()
Set MyDynaset = MyDB.CreateDynaset("Customers")
'The following line will generate an error.
MyDynaset.FindFirst "[company name]='Babu Ji's Exports'"
If Not MyDynaset.nomatch Then
MsgBox MyDynaset.[company name]
Else
MsgBox "No Match"
End If
MyDynaset.Close
End Function
Function FindaPost3 ()
Dim MyDB As Database, MyDynaset As Dynaset
Set MyDB = CurrentDB()
Set MyDynaset = MyDB.CreateDynaset("Customers")
'Find this company (with an apostrophe in the name).
MyDynaset.FindFirst "[company name]=""Babu Ji's Exports"""
If Not MyDynaset.nomatch Then
MsgBox MyDynaset.[company name]
Else
MsgBox "No Match"
End If
MyDynaset.Close
End Function
Function FindQuote1 ()
Dim MyDB As Database, MyDynaset As Dynaset
Set MyDB = CurrentDB()
Set MyDynaset = MyDB.CreateDynaset("Employees")
'the following line generates a compile error.
MyDynaset.FindFirst "[notes] like '*"The art of the cold_
call."*'"
If Not MyDynaset.nomatch Then
MsgBox MyDynaset.[Last Name]
Else
MsgBox "No Match"
End If
MyDynaset.Close
End Function
Function FindQuote2 ()
Dim MyDB As Database, MyDynaset As Dynaset
Set MyDB = CurrentDB()
Set MyDynaset = MyDB.CreateDynaset("Employees")
'find this note that contains a quote.
MyDynaset.FindFirst "[notes] like '*" & Chr(34) & "The art of_
the cold call." & Chr(34) & "*'"
If Not MyDynaset.nomatch Then
MsgBox MyDynaset.[Last Name]
Else
MsgBox "No Match"
End If
MyDynaset.Close
End Function
Keywords: kbinfo kbprogramming KB104823