Link to home
Start Free TrialLog in
Avatar of Grant Fullen
Grant Fullen

asked on

Input box Adoquery

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

ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Grant Fullen
Grant Fullen

ASKER

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

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


Thanks