Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT...MAX Question for SVANELS

Status
Not open for further replies.

BillKilgore

Programmer
Mar 17, 2002
60
US

Steven,

I read the answer you provided kingosticks in his query 102-1051893 but
I'm unclear as to exactly how to apply it. My difficulty is identical to
his and I'm getting the same, '...field not found' error when the line
with the 'X' is encountered.

(I use the string, loc_bar_number, as a check point for a partial run before
it gets optmized in the Text statement.)

The table name: Bars.
The field name: barnumber.

procedure TfmBarInventoryInput.DBEdBarNumberChange(Sender: TObject);
Var loc_bar_number : string;
Begin
loc_bar_number := '0';
with ADOQBars do
begin
close;
SQL.clear;
SQL.Add('SELECT MAX(BarNumber) FROM bars');
Active := True;
open;
X loc_bar_number := FieldByName('BarNumber').AsString;
DBEdBarNumber.Text := loc_bar_number;
SQL.Clear;
close;
end;
End;

My status is also about the same as kingosticks, except he understood your answer, in that I havn't done any SQL for quite a while and, prior to this assignment, never in Delphi.
Thank you for your consideration.

Bill Kilgore


 
since you are using the MAX function, the "name" of the field doesn't exist. you would need to explicitly name the "new" column:

SQL.Add('SELECT MAX(BarNumber) As BarNumber FROM bars');


then the FieldByName assignment will work.

HTH

leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top