I want the user to be able to choose from a dropdown Combobox listing some of the fields of the database, then below enter a search term and all then all the results that meet the query be displayed in the dbgrid. I’m not sure how to link the current value of the ComboBox into the sql statement. I tried using this
begin
with ADOQuery do begin
Close;
SQL.Clear;
SQL.Add ('SELECT * FROM List WHERE combobox1.text =' + QuotedStr (Asearchterm.Text));
Open;
And it doesn’t work. The error i’m getting is “The parameter combobox1.text has no default value”. Any ideas?
If you’re wanting to use the combobox1 text value as part of the sql statement, you’d set up the sql string along the lines of
is probably what you’re looking for. I added the extra quotes around the QuotedStr because I’m guessing that the filter is not always going to be numeric values. This will work for numeric as well as non-numeric values.