Solved

Parameter query

Posted on 1998-01-07
2
225 Views
Last Modified: 2010-04-04
I have a table with 6 fields and I will like to
link the query parameters from 5 edit controls.  I can do the linking with 1 edit control, but  I need help to extend the linking to five controls.  My source code is like this:

procedure TForm1.Button1Click(Sender: TObject);
var SQL_Pattern, Temp: String;
begin
 if Query1.State <> dsInactive then
 Query1.Close;
 Query1.Clear;
 if Edit1.Text <> '' then begin
 SQL_Pattern := Edit1.Text;
 Temp := 'SELECT * FROM CROP WHERE Protein = ';
 TEmp := Temp + SQL_Pattern;
 Query1.SQL.ADD (Temp);
 Query1.Open;
end;
The other 4 fields are oil, height, yield, and lodging.
I will also appreciate solving the problem in any way that is possible.  Thank you for your help.
0
Comment
Question by:Ogunbo
2 Comments
 
LVL 2

Accepted Solution

by:
mvz121697 earned 70 total points
ID: 1355750
Try something like this:
In this example i assumed that it are all numeric fields,
except the OIL-field (Look at the quotes) :

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add( 'SELECT * FROM CROP ');
Query1.SQL.Add( 'WHERE Protein = ' + Edit1.Text);
Query1.SQL.Add( ' AND oil = "' + Edit2.Text+'"');
Query1.SQL.Add( ' AND height = ' + Edit3.Text);
Query1.SQL.Add( ' AND yield = ' + Edit4.Text);
Query1.SQL.Add( ' AND lodging = ' + Edit5.Text);
Query1.Open;


0
 

Author Comment

by:Ogunbo
ID: 1355751
Dear  MVZ:
Thank you so much for your help.  You know, this was my first time to post a message and in less than 24 hrs, the question had been answered.  This is great.  Please keep up the good work. I am also thankful to the folks at the experts-exchange site.  May God bless your efforts.

As for the problem, I tried your suggestion for most of the night and it didn't work.  The program compiled successfully, so I knew it must be something small.  This morning, I figured that I needed to put >= or <= in the code.  Otherwise, the values I was using in testing the program did not meet a match, hence the query was returning no records.  However, I have few other questions and I hope you'll find time to answer it.

1.  I have a field called Disease_Resistant and each record will either be yes or no.  I will like to use a check box or a radio button for instance to be used for including crops with yes in their field with the result from the edit boxes.  What syntax do you suggest that I use? Or

2.  If I use a radiobox to hold 2 radio radio buttons, i.e I only want one of the buttons to be operative at a time: with the first button saying : Disease resistant, and the second radiobutton saying: Non resistant.  What will the syntax be like for someone to check on one of the buttons?

Once again thank you very much.  May the Blessings of God be with you and your family.

Sincerely,
  Ogunbo
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question