Solved

Parameter query

Posted on 1998-01-07
2
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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