Iam using VB6 (ADO) & in back end Ms Access. I have two option buttons i.e optName & OptPhono.For performing search i use a cmdSearch
button & a text box to write what i want to search.
Both code for searching works fine but the problem is, i can choose only one code at a time.
For example if i want to search name them i make remarks all the lines
of Phono search which u can see below & vice virsa.
Please can u guide me that how can i use both code under cmdSearch so that at run
time if i want to perform search by clicking the OptName then i can do it &
if i want to seacrh by Phono then i can choose the optPhono for seacrhning.
One way is to do Case i.e
case optNmae
code
Case OptPhone
Code
But iam unable to do it.please can u write the complete code to do with it or there
is any other way to do it.
Thanks a lot for the help.
Private Sub cmdSearch_Click()
Dim opt As String
'--------------Code for Searching Name from Datdabase
Set rec = cn.Execute("select * from student where Name LIKE '" & Text1.Text & "%'")
If rec.BOF = True And rec.EOF = True Then
MsgBox "record not found"
Else
txtRoll.Text = rec.Fields(0)
txtName.Text = rec.Fields(1)
txtFather.Text = rec.Fields(2)
txtPhono.Text = rec.Fields(3)
End If
'--------------Code for Searching Phono from Datdabase
Set rec = cn.Execute("select * from student where phono=" & opt1)
If rec.BOF = True And rec.EOF = True Then
MsgBox "record not found"
Else
txtRoll.Text = rec.Fields(0)
txtName.Text = rec.Fields(1)
txtFather.Text = rec.Fields(2)
End If
End sub