Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Database using SQL Query 1

Status
Not open for further replies.

Joell

Technical User
Oct 4, 2002
10
AU
I have got a few ComboBoxes that contain the fields of a table (GetFieldNames) and edit boxes that allows the user the key in the value(s) corresponding to the Field selected in the combo box. Is there a way the values of these comboboxes and editboxes be embedded in a SQL Query?

For example, what i am trying to do is --

'Select * from Candidate
where 'combobox1.text' = 'edit1.text'
and 'combobox2.text' = 'edit2.text' ';

Joell

 
Forget SQL. I'm off using the filter property of a TTable.
Just another quick question though, instead of the user having to type in '' when searching for a value, is there any way it can be embedded in the code. What I've got now is

Table1.Filter:=combobox1.Text+ combobox3.text+ edit1.text;

Doing this doesnt seem to work

Table1.Filter:=combobox1.Text+ combobox3.text+ 'edit1.text';

Joell
 
You need something like this, if it's a string or date value:-

Filter := combo1.text + ' = ''' + edit1.text + '''';

or eg.:-

Filter := combo1.text + ' = '+ strToInt(edit1.text) +
' OR '+combo2.text + ' = '''+edit2.text+'''';
 
Weez, instead of ""+edit2.text"" use

+ QuotedStr(edit2.text) Steven van Els
SAvanEls@cq-link.sr
 
Ah-ha. The QuotedStr thingy works. Thanks =)

Joell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top