Good day,

I created a simple search in sql. inside the textchange event. everythis seem to be ok for text box. i want to have another search with the other text but this time i want to use the first search and concat it with the next condition..

here is the scenario...

once i type in the textbox and press enter all the record with the this character will return..

this is filtered in the first textbox

SELECT 
        MRN
        ,FIRSTNAME
        ,MIDDLENAME
        ,LASTNAME
        ,GENDER
        ,BIRTHDATE 
        ,MARITAL_STATUS

        FROM Patient_Information 

        WHERE 
        FIRSTNAME LIKE @FIRSTNAME+'%'

how could i put the other filter that was will be filtered by other textbox

thanks

Recommended Answers

All 2 Replies

You can declare a var to hold your query in the declarations part of your form (before the first sub) and a second one to hold your query criteria. This will give your vars scope for all events in this form and allow you to use them in 2 or more different subs.

When coding the textchanged events instead of declaring a string for your query, use the ones that have scope the entire form. Check if the query_criteria one has a value assigned and if it does concatenate your new criteria at the end (make sure you concatenate a space in there as well). If it doesn't have a value assign it one.

execute your query by concatenating the 2 string vars (the query and the query criteria) for each of the 2 subs.

very well said adam k. thanks for your advice about that. it helps me alot..

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.