Web Development

General discussion


"LIKE" Query for Access DB

By alex ·
I have an Access database that I must perform a close-to type query using Visual Basic 6.0, using a Dyanaset type recordset. Currently I use the FindFirst method for pulling data I need and was told that the LIKE operator would function inside the Findfirst method, but I have not been able to make it work. Has anyone used it in this way, or have a new suggestion?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

"LIKE" Query for Access DB

by roc180 In reply to "LIKE" Query for Access D ...

The following code will work

Sub Test_Find()
Dim Rst As Recordset
Dim AccessDB as Database

Set AcessDB=OpenDatabase("C:\My.mdb")
Set Rst = AccessDB.OpenRecordset("SELECT * FROM TBL1", dbOpenDynaset)
With Rst
If .RecordCount > 0 Then
.FindFirst "F_Name LIKE 'n*'"

If .NoMatch Then
MsgBox "No Recs match search"
MsgBox "Found Record!!!" End If
End If

End With
Set Rst = Nothing

Set AcessDB=Nothing

End Sub

Good Luck

Neal Martinelli

Collapse -

"LIKE" Query for Access DB

by alex In reply to "LIKE" Query for Access D ...

Your code sample did help me figure out what i wanted to do, round about. One problem I still have is in the following line :

.FindFirst "F_Name LIKE 'n*'"

in making n a string variable that is retrieved from a text box input. If you couldemail that answer that'd be great! Thx

Collapse -

"LIKE" Query for Access DB

by alex In reply to "LIKE" Query for Access D ...

This question was closed by the author

Related Discussions

Related Forums