I have developped a program using vb6 used by a college to store students scores in diferent courses. My problem is that i want to create a button users can use to search for a specific record using the students admission number. I do not have much knowlegde in finding records but i stubled on the following code which when i run, does not generate anything.
Private Sub cmdSearch_Click()
Dim var As String, bmark As String
var = InputBox("Enter your name", "Searching...")

With datAcademic.Recordset
.Bookmark = bmark
.FindFirst ("Adm_no like "" + var + """)

If .NoMatch Then
MsgBox "sorry no student found!"
.MoveNext
.Bookmark = bmark
End If
End With
End Sub
I dont know why the code is not working, could somebody please send some help? I request someone to explain the meaning of .bookmark=bmark and why enclose the ("Adm_No like "" + var + """) in all those quotations, lease your help will be valuable to me.

consider quick response in detail.

Hi,

Try this :

With datAcademic.Recordset
.Bookmark = bmark
.FindFirst ("Adm_no Like '*" + var + "*'")

Regards
Veena

Hi,

Try this :

With datAcademic.Recordset
.Bookmark = bmark
.FindFirst ("Adm_no Like '*" + var + "*'")

Regards
Veena

thanks for the quick reply. i have tried and it worked no more stress, but would you mind to explain why the single quote before and after the * mark? please.

Hi,

* acts as a WildChar..
you need to give % if, database is other than Access..

Code may not be working because of the Case change..
you can try this as well..
.FindFirst ("UCase(Adm_no) Like '*" + UCase(var) + "*'")

REgards
Veena

This question has already been answered. Start a new discussion instead.