Charlie Guest
|
Posted: Wed Jun 08, 2005 2:11 pm Post subject: Can it be done |
|
|
Hi all. I hope that you can help me with my learning curve.
I'm using Delphi 5 with dBase files with TQuery and TDataSource. Grid is
TDBGrid.
I need to populate a grid with data from the orders table as follows:
Column1 would be the Order Due Date.
Column2 would be the Total of Widgets ordered for that day if any
Column3 would be the Total of Gidgets ordered for that day if any
Column4 would be the Total of WhatsIts ordered for that day if any
In the Orders table are Boolean fields set to True if that order is for
Widgets, Gidgets or WhatsIts. The field ItemTotal contains the total of
Widgets, Gidgets, or WhatsIts as applicable.
The following code gives me a grid with the Order Due Dates but nothing for
the other columns.
with qryDueDate_, SQL do
begin
dWidgetsBalance := 0;
dGidgetsBalance := 0;
dWhatsItsBalance := 0;
dtpDueDate.Date := (Now + 1);
Clear;
Add('SELECT DueDate, ItemTotal, bWidgets, bGidgets, bWhatsIts From
Orders');
Add('WHERE DueDate >= :sDueDate');
qryDueDate_.ParamByName('sDueDate').AsDate := dtpDueDate.Date;
Add('Group By DueDate, BoxTotal, bWidgets, bGidgets, bWhatsIts');
Add('Order by DueDate');
Open;
while not EOF do
begin
if (qryDueDate_.FieldByName('bWidgets').AsString = 'True') then
dWidgetsBalance := dWidgetsBalance +
qryDueDate_ItemTotal.AsInteger
else if (qryDueDate_.FieldByName('bGidgets').AsString = 'True') then
dGidgetsBalance := dGidgetsBalance +
qryDueDate_ItemTotal.AsInteger
else if (qryDueDate_.FieldByName('bWhatsIts').AsString = 'True')
then
dWhatsItsBalance := dWhatsItsBalance +
qryDuedate_ItemTotal.AsInteger;
Next;
end;
Thank you,
Charlie
|
|