Well im currently developing a system, a admission system to be exactly
im having issues with if else statement through the search engine of my system

so here it goes
i have a database/table that contains name and status

the name can be any string"not a big deal"
then the status can be Instructor or Student

i have this code using to search for a record

Private Sub txtSearch_Change()
If cboSearch.Text = "name" Then
Adodc1.RecordSource = "select name, status from Login where name like '%" + txtSearch.Text + "%'"
Adodc1.Refresh

else if cboSearch.text = "status" then
Adodc1.RecordSource = "select name, status from Login where status like '%" + txtSearch.Text + "%'"
Adodc1.Refresh

end if
end sub

question: how can i filter the records of only the given status "instructor and student" and meeting the designated field "if they are search for status or name with a keyword"
because my adodc1 contains name, and status (student, instructor, faculty and facilitator)


i have the following code but it dosent work for me

If cboSearch.Text = "Student Name" Then
Adodc1.RecordSource = "select name, status from Login where name like '%" + txtSearch.Text + "%'" and status = 'Instructor' or status = 'student'
Adodc1.Refresh

in short, how can i need to meet at least 2 of the three condition to post a record, the keyword of the name and at least one of the status

You need to frame the query dynamically at run time and execute the same based on the combo value.

Try the following -

If cboSearch.Text = "Student Name" Then
Adodc1.RecordSource = "SELECT name, status FROM Login WHERE name LIKE '%" & txtSearch.Text & "%' AND status = 'Instructor'"
Adodc1.Refresh
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.