Using controls to create sql statement
Posted on 2006-10-22
I want to create a text box that builds a sql statement as users add variation options to text boxes above.
I have text1 which is for surname, text 2 for first name and check 1 which is for life member.
I have a text box called sqlsrch. This is defaulted to "select * from members order by surname"
When the user enters LIT into the surname box, i want the sql statement in sqlsrch box to update to be "select * from members where surname LIKE '%LIT%' order by surname"
And then when the life member check is ticket to make the same statement "select * from members where surname LIKE '%LIT%' and lifemem = 1 order by surname"
And so on.
I have seen this done in an application that I once used for work. How do you make this happen? There has to be an easier way that to have several if tests to filter which option is being used?