Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Input box Adoquery

Posted on 2009-04-09
5
Medium Priority
?
268 Views
Last Modified: 2012-05-06
I need to do a lookup of a account number. I want to use a input box.
Looking for and example to use my adoquery1 to move the dbgrid to the correct record that matches my input box values.
table:= CustomerInfo
Field:=  Account Number.
my sql.text is select * from CustomerInfo.
var
  value : string;
 
begin
  // Keep asking the user for their town
  repeat
    value := InputBox('Test program', 'Please type your town', 'Cardiff');
  until value <> '';
 
  // Show their name
  ShowMessage('Your town is '+value);

Open in new window

0
Comment
Question by:Grant Fullen
[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
  • 2
5 Comments
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 24113533
if AdoQuery1.Locate('TOWN', Value, [loCaseInsensitive]) then
  ShowMessage('Record located');
0
 
LVL 18

Assisted Solution

by:Johnjces
Johnjces earned 500 total points
ID: 24116462
Here are a couple other suggestions:  (Spaces and single quotes are important so note them).

Also, the verb 'Like' can be '=' for an exact match..

procedure Button1Click(Sender: TObject);
begin
 ADOQuery1.Close;
 ADOQuery1.SQL.Clear;
 ADOQuery1.SQL.Add('Select * From CustomerInfo where AccountNumber Like :SrchStr');
 ADOQuery1.Parameters[0].Value := '%'+ Value + '%';
 ADOQuery1.Open;
end;

or...

procedure Button1Click(Sender: TObject);
begin
 ADOQuery1.Close;
 ADOQuery1.SQL.Clear;
 ADOQuery1.SQL.Add('Select * From CustomerInfo where AccountNumber Like '+ QuotedStr(Value));
 ADOQuery1.Open;
end;

John
0
 

Author Comment

by:Grant Fullen
ID: 24119787
error
Paramater AccountNumber Has No defalt value......

procedure TForm1.ToolButton2Click(Sender: TObject);
var
  value : string;
 
begin
    value := InputBox('Invoice Number Lookup ', 'Please type your Number', '');
   ShowMessage(value);
  datamodule2.ADOQuery1.Close;
 datamodule2.ADOQuery1.SQL.Clear;
 datamodule2.ADOQuery1.SQL.Add('Select * From CustomerInfo where AccountNumber Like '+ QuotedStr(Value));
 datamodule2.ADOQuery1.Open;

Open in new window

0
 
LVL 18

Expert Comment

by:Johnjces
ID: 24119865
Is the AccountNumber field spelled correctly?

Access is interpreting AccountNumber as a parameter not a fieldname which probably means that this field has a different spelling.

And last, try:

datamodule2.ADOQuery1.SQL.Add('Select * From CustomerInfo where AccountNumber Like ' + Value);

Sometimes I get confused on when a quoted string in an SQL Query is needed when piecing together strings.

John


0
 

Author Closing Comment

by:Grant Fullen
ID: 31568812
Thanks
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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