Link to home
Start Free TrialLog in
Avatar of zippy221
zippy221

asked on

Search

Hi, I want to search a database.  I want to be able to search by either age or eye color.  I have two radio buttons.  One called radEye and one called radAge.  I have a text box where I will input what I am searching for called txtSearch.  And, I have a command button called cmdSearch to press when I am ready to search.  Any help or creative ideas would be much appreciated.
Avatar of AZWolf7
AZWolf7

OK, need more info on this, but here's the gist of it:

Dim sSQL as string

sSQL = "select * from Mytable where "

If radEye then
     sSQL = sSQL & " eyecolor = '" & txtSearch & "'"
Else
     sSQL = sSQL & " age = " & CInt(txtSearch)
End If

This code made the following assumptions:
the table is called Mytable
the fields are called eyecolor and age respectively
eyecolor is a string
age is an integer
they have selected one of the values radEye or radAge
if they selected radAge, they entered a valid number



Ooops, it also assumes you can run this dynamically built SQL statement. The theory is create the SQL statement, and execute it to get your recordset you want.

Avatar of zippy221

ASKER

Okay here is more info.  There are 3 text boxes that display the information from the database.  These text boxes are: txtEyeColor, txtAge, txtName.  The database is called dbStudy.  The table is called tblColor.  I will need to create some sort of search where the user can search by either Eye Color or Age.  
ASKER CERTIFIED SOLUTION
Avatar of AZWolf7
AZWolf7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial