Select Max(col name) Expr1000



I am trying to select a MAX value from a column and I have in the past added
my own temporary column to return the max value into but I could not get
that to work. I noticed that the query returned the value into a column
called expr1000. Does it always return that column name with the max value
or is there something else I should do.

MainAdoQuery.Close;
sSql := 'Select MAX ([Piece Number]) ' +
' FROM [' + MainAdoDataSet.CommandText + ']' +
' Where [Item Number] = ' + '"' + MainForm.KeyIdEdit.AsString + '"';
MainAdoQuery.SQL.Text := sSql;
try
MainAdoQuery.Open;
except
raise;
Exit;
end;
MainAdoQuery.GetFieldNames(MainForm.ListBox1.Items);
ShowMessage(MainAdoQuery.FieldbyName('Expr1000').AsString);


.



Relevant Pages