General discussion

Locked

"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.

3 total posts (Page 1 of 1)  
| 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
.MoveFirst
.FindFirst "F_Name LIKE 'n*'"

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

.Close
End With
Set Rst = Nothing

AcessDB.close
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

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums