How Can I Create a Multiple Search Criteria?

I have been assigned a task of creating the above for one of our database programs. I have to create a number of search criterias, based on certain fields, and if none of the search criteria is entered, it should return all records.

Please give my some general idea on how I can achieve such a thing. Any code sample would be most welcome, but at least some ideas on how to go about doing this would be good enough.

Thank you in advance for your help.

Elizabeth.

Comments

  • : I have been assigned a task of creating the above for one of our database programs. I have to create a number of search criterias, based on certain fields, and if none of the search criteria is entered, it should return all records.
    :
    : Please give my some general idea on how I can achieve such a thing. Any code sample would be most welcome, but at least some ideas on how to go about doing this would be good enough.
    :
    : Thank you in advance for your help.
    :
    : Elizabeth.
    :


    It depends alot on the database you are using... for example if you are using sql server you can create stored procedures and pass the parameters into them,

    otherwise you can append the criteria into your sql statment like so:
    [code]
    'say you have got a user input value of 10 in intValue
    dim strSQL as String

    strSQL = "Select * from tblName where YourSearchFieldName = " & intValue

    [/code]

    you can also use AND statements in your sql to apply multiple search keys, ie ...where yoursearchfieldname =" & yourVar & " AND YourField2 =" & yourVar2

    also if the value is a string you will probably need single quotes around it, ie... where yourField ='" & strValue & "'"


    hope this gets you on the right track.
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion