Autor Beitrag
Bruce
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 80



BeitragVerfasst: Sa 05.04.03 19:38 
Hallo!
Ich hab das Gefühl, meine Frage ist ziemlich dämlich, aber ich komm nicht weiter und finde auch nichts brauchbares.

Ich arbeite gerade an einer Art Haushaltsbuch. Da gibt´s dann z.B. eine
DBase-Tabelle "Ausgaben", auf die ich mit TTable zugreife. Jetzt will ich über ein berechnetes Feld die Summe der eingegebenen Beträge anzeigen. Wie krieg ich das hin?

Weil ich nichts gefunden habe, wollte ich jetzt ins OnCalcField-Ereignis eine Schleife setzten, die jeweils die Datensätze von Anfang bis Ende durchgeht und addiert, da funktioniert aber was nicht und mir kommt das ganze von Anfang an auch "unelegant" vor.

Wie macht man das richtig? Oder geht das nur mit manuellem Zählen und addieren?

Danke und
Gruß, Bruce
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Sa 05.04.03 20:02 
ausblenden Quelltext
1:
SELECT SUM(Ausgabe) AS Gesamtausgabe FROM tabelle					



gr€€tz
Bruce Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 80



BeitragVerfasst: Sa 05.04.03 20:17 
SELECT SUM(Ausgabe) AS Gesamtausgabe FROM tabelle

Das ist doch SQL, ich hab aber ttable. Geht das damit nicht?

Gruß, Bruce
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Sa 05.04.03 20:39 
hmmm

hmm hab hier ein meinem table auch ne eigenschaft sql probiers mal damit.


gr€€tz
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: So 06.04.03 23:28 
hallo bruce!

Zitat:

Das ist doch SQL, ich hab aber ttable. Geht das damit nicht?

wo du recht hast, hast du recht ;)
sql kann mit Ttable nicht so gut.
entweder ziehst eine TQuery aufs form, trägst als databasename dein datenverzeichnis oder einen alias ein und zeigts mit deiner datasource auf die TQuery, dann kannst sql verwenden.
oder du bleibst bei Ttable und summierst die werte sequentiell

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
  with table1 do begin
    while not eof do begin
      gesamtausgabe:= gesamtausgabe + fieldbyname('summe').asInteger;
      next
    end;
  end;


mfg, stefan