Solved

Parameter query

Posted on 1998-01-07
2
222 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now