TeChNiCh
asked on
Table calculating
Well lets see... i made a table Paradox 7.
when i push button1 then i want the program to calculate
all Columns 3 and label1.caption will be the answer
ex: i got 20 rows in the table and all row has column 3
and i want the proggie to check 1st column 3 and add that with 2nd column 3 and then add it with 3rd column and label1.caption will show the right answer
when i push button1 then i want the program to calculate
all Columns 3 and label1.caption will be the answer
ex: i got 20 rows in the table and all row has column 3
and i want the proggie to check 1st column 3 and add that with 2nd column 3 and then add it with 3rd column and label1.caption will show the right answer
Now grap the total like this
Lable1.Caption := Query1.FieldByName('TotalO fAll').AsS tring;
Lable1.Caption := Query1.FieldByName('TotalO
Here it is all together
with Query1 do begin
with SQL do begin
Clear;
Add('SELECT Sum(Feild1) + Sum(Feild2) + Sum(Feild3) AS TotalOfAll');
Add('FROM Table1');
end;
Open;
Lable1.Caption := FieldByName('TotalOfAll'). AsString;
Close;
end;
with Query1 do begin
with SQL do begin
Clear;
Add('SELECT Sum(Feild1) + Sum(Feild2) + Sum(Feild3) AS TotalOfAll');
Add('FROM Table1');
end;
Open;
Lable1.Caption := FieldByName('TotalOfAll').
Close;
end;
Of course with all three fields in queston the Data Type needs to be of a numeric type for this to work.
I think the intention was to just get the total of column 3...
with TQuery.Create(nil) do
try
DatabaseName := '???';
SQL := 'select sum(column3) from table1';
Open;
Label1.Text := Fields[0].AsString;
finally
Free;
end;
with TQuery.Create(nil) do
try
DatabaseName := '???';
SQL := 'select sum(column3) from table1';
Open;
Label1.Text := Fields[0].AsString;
finally
Free;
end;
>>>i want the program to calculate all Columns 3
Well now I am a bit confused hopefully TeChNiCh will clarify it for us. I thought it was a typo and meant to read as 3 Columns. :>)
How have you been doing Hamlet? I am glad to be working a thread with you.
Well now I am a bit confused hopefully TeChNiCh will clarify it for us. I thought it was a typo and meant to read as 3 Columns. :>)
How have you been doing Hamlet? I am glad to be working a thread with you.
ASKER
Hamlet understood correct
ASKER
Or i would like all Column 3 to be added not just on 1 row but on all rows
ASKER
I also get an error when i change the table... Database allready in use or some
ASKER
How can i do so if Column3Enterpressed then autoupdate the label1 and also create a new row in the table.... thats the only problem at the moment
I think we need more backgorund on what you are doing...
It sounds like you have a grid that is displaying the values?
Is this grid connected to a TTable or a TQuery?
Are the values meant to be editable for all columns or just column 3?
The more details you give the better.
(p.s. Hi CrazyOne. I'm doin' well. Looking forward to a big trip in just over a week. I won't be going near a keyboard for almost two weeks! Yay!)
It sounds like you have a grid that is displaying the values?
Is this grid connected to a TTable or a TQuery?
Are the values meant to be editable for all columns or just column 3?
The more details you give the better.
(p.s. Hi CrazyOne. I'm doin' well. Looking forward to a big trip in just over a week. I won't be going near a keyboard for almost two weeks! Yay!)
ASKER
I got a grid connected to Table and Column 3 has
number value.
im doing like:
Column1 | Column2 | Column3
Income from Description Cash
im very bad at explaining sorry for that :P
number value.
im doing like:
Column1 | Column2 | Column3
Income from Description Cash
im very bad at explaining sorry for that :P
TeChNiCh,
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
You have 10 of the 16 questions you've asked at Experts Exchange still open, dating back to March of 2001. That, to put it mildly, is a horrible grading record.
Part of being a member here is closing your questions. Please take care of these in short order.
https://www.experts-exchange.com/questions/20463499/Show-only-a-few-hits-at-the-time.html
https://www.experts-exchange.com/questions/20476242/UPDATE-table.html
https://www.experts-exchange.com/questions/20494438/Trying-to-delete-a-record.html
https://www.experts-exchange.com/questions/20098209/Memo1-Specify.html
https://www.experts-exchange.com/questions/20099958/Databases.html
https://www.experts-exchange.com/questions/20123196/Table-calculating.html
https://www.experts-exchange.com/questions/20163381/Print-text-to-printer-as-HTML.html
https://www.experts-exchange.com/questions/20166816/Keyboard-Lights.html
https://www.experts-exchange.com/questions/20180411/Listbox1-Columns.html
https://www.experts-exchange.com/questions/20254546/Download-HTML.html
Netminder
EE Admin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'SELECT Sum(Feild1) + Sum(Feild2) + Sum(Feild3) AS TotalOfAll
FROM Table1';