Autor Beitrag
dragi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Mo 21.07.03 09:33 
Hallo,

ich habe ein problem mit der preview funktion von Quickrep. Ich nutze Quickrep um eine access datenbank auszudrucken bzw. deren Inhalt. Wenn mein Programm läuft, ich daten in der Tabelle änder, zeigt mir die preview Funktion diese Änderungen nicht an. Ich muss erst mein Programm beenden und wieder starten, dann ist das Preview aktuell.

Gibt es eine möglichkeit quickrep.preview zu sagen das es sich aktuallisieren soll?

Gibt es auch noch eine Möglichkeit das Quickrep auch die Tabelle, also die Linien um die Felder anzeigt?

Vielen Dank

dragi
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Mo 21.07.03 19:19 
Vielleicht könnt ihr ja bei dem code was entdecken?

Unit 1
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, DBCtrls, DBGrids, Grids, Calendar, StdCtrls, DB,
  ADODB, Mask, QuickRpt, Menus;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    ADOConnection1: TADOConnection;
    DataSource1: TDataSource;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    ADOTable1: TADOTable;
    Label1: TLabel;
    Label2: TLabel;
    DBNavigator1: TDBNavigator;
    Button1: TButton;
    DBGrid1: TDBGrid;
    Button2: TButton;
    GroupBox2: TGroupBox;
    Calendar1: TCalendar;
    Label4: TLabel;
    Label5: TLabel;
    Button3: TButton;
    Button4: TButton;
    Label3: TLabel;
    procedure Calendar1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);


  
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
  Calendar1.Month := Calendar1.Month - 1;
  If Calendar1.Month = 1 then
    Label4.Caption := 'Januar';
  If Calendar1.Month = 2 then
    Label4.Caption := 'Februar';
  If Calendar1.Month = 3 then
    Label4.Caption := 'März';
  If Calendar1.Month = 4 then
    Label4.Caption := 'April';
  If Calendar1.Month = 5 then
    Label4.Caption := 'Mai';
  If Calendar1.Month = 6 then
    Label4.Caption := 'Juni';
  If Calendar1.Month = 7 then
    Label4.Caption := 'Juli';
  If Calendar1.Month = 8 then
    Label4.Caption := 'August';
  If Calendar1.Month = 9 then
    Label4.Caption := 'September';
  If Calendar1.Month = 10 then
    Label4.Caption := 'Oktober';
  If Calendar1.Month = 11 then
    Label4.Caption := 'November';
  If Calendar1.Month = 12 then
    Label4.Caption := 'Dezember'
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Calendar1.Month := Calendar1.Month + 1;
  If Calendar1.Month = 1 then
    Label4.Caption := 'Januar';
  If Calendar1.Month = 2 then
    Label4.Caption := 'Februar';
  If Calendar1.Month = 3 then
    Label4.Caption := 'März';
  If Calendar1.Month = 4 then
    Label4.Caption := 'April';
  If Calendar1.Month = 5 then
    Label4.Caption := 'Mai';
  If Calendar1.Month = 6 then
    Label4.Caption := 'Juni';
  If Calendar1.Month = 7 then
    Label4.Caption := 'Juli';
  If Calendar1.Month = 8 then
    Label4.Caption := 'August';
  If Calendar1.Month = 9 then
    Label4.Caption := 'September';
  If Calendar1.Month = 10 then
    Label4.Caption := 'Oktober';
  If Calendar1.Month = 11 then
    Label4.Caption := 'November';
  If Calendar1.Month = 12 then
    Label4.Caption := 'Dezember'
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label5.Caption := IntToStr(Calendar1.Year);
  If Calendar1.Month = 1 then
    Label4.Caption := 'Januar';
  If Calendar1.Month = 2 then
    Label4.Caption := 'Februar';
  If Calendar1.Month = 3 then
    Label4.Caption := 'März';
  If Calendar1.Month = 4 then
    Label4.Caption := 'April';
  If Calendar1.Month = 5 then
    Label4.Caption := 'Mai';
  If Calendar1.Month = 6 then
    Label4.Caption := 'Juni';
  If Calendar1.Month = 7 then
    Label4.Caption := 'Juli';
  If Calendar1.Month = 8 then
    Label4.Caption := 'August';
  If Calendar1.Month = 9 then
    Label4.Caption := 'September';
  If Calendar1.Month = 10 then
    Label4.Caption := 'Oktober';
  If Calendar1.Month = 11 then
    Label4.Caption := 'November';
  If Calendar1.Month = 12 then
    Label4.Caption := 'Dezember'
end;

procedure TForm1.Calendar1Change(Sender: TObject);
begin
  DBNavigator1.BtnClick(nbInsert);
  DBEdit1.Text := IntToStr(Calendar1.Day) + '.' + IntToStr(Calendar1.Month) + '.' + IntToStr(Calendar1.Year);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.QuickRep1.Preview;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Form2.QuickRep1.PrinterSetup;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if MessageDlg('Wirklich beenden?',
                mtConfirmation,
                [mbYes,mbNo],
                0)=mrNo then
    CanClose:=False
end;

end.


und Unit2
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, QuickRpt, QRCtrls, DB, ADODB, StdCtrls;

type
  TForm2 = class(TForm)
    QuickRep1: TQuickRep;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    DataSource1: TDataSource;
    ColumnHeaderBand1: TQRBand;
    DetailBand1: TQRBand;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    procedure QuickRep1StartPage(Sender: TCustomQuickRep);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.QuickRep1StartPage(Sender: TCustomQuickRep);
begin
  QRLabel5.Caption := Form1.Label4.Caption + Form1.Label5.Caption;
end;

end.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 22.07.03 09:25 
Hallo!

dragi hat folgendes geschrieben:
Ich muss erst mein Programm beenden und wieder starten, dann ist das Preview aktuell.

Dann pack doch ein Button auf das Form und beim Klick auf diesem erstellst du die Preview noch mal neu.

Gruß
Tino
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Di 22.07.03 10:49 
Leider geht das auch nicht. Das preview wird einfach nicht zur Laufzeit aktualisiert, bzw. sieht es so aus, das quickrep die Tabelle nur beim Programm start aktualisiert sich danach aber nicht mehr darum kümmert ob sich die Tabelle geändert hat!

Weiss auch nicht mehr weiter
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Di 22.07.03 11:25 
Selbst beim Drucken aktuallisiert QuickRep nicht. Wenn ich während der Laufzeit was änder bleibt der Druck sowie das Preview bei der Ausgangstabelle :(
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 22.07.03 12:11 
Hallo!

Vielleicht verstehe ich das Problem auch nicht aber

Du hast eine Datenbank und eine Quickreport Komponente. Diese beiden hast du mit einander verbunden und anschließent sagst du dann der Quickreport Komponente sie soll die Preview erstellen, oder?

Wo ist das Problem noch mal der Quickreport mitzuteilen sie soll die Preview erstellen?

Gruß
Tino
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Di 22.07.03 12:39 
Das verstehe ich jetzt nicht so ganz :)

Ich habe 2 Formulare:

Form1 besitzt 2 Edit Felder die in die Datenbankschreiben sowie einen Button Preview und Drucken.

Form 2 enthält den Quickreport.

Starte ich das Programm und drücke auf Preview zeigt mir Quickreport die Tabelle an so wie es auch gedacht ist. Dann schliesse ich die Vorschau und trage über das Formular 1 weiter Daten in die Datenbank. Drücke ich jetzt auf preview sehe ich immer noch die unveränderte Tabelle aber nicht die neuen Daten. Wie soll ich denn mehrmals preview sagen wenn der Button doch bei onClick doch eh Form2.Quickrep1.preview; ausführt?

Wie gesagt, bin newbie vielleicht habe ich auch einen Denkfehler in der Sache!
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 22.07.03 12:58 
Hi!

Habs jetzt glaube ich verstanden :-D

Ich bin aber nicht sicher ob ich die Lösung für dein Problem habe da ich mit den Quickreport Komponenten nicht arbeite. Aber mal etwas was du ausprobieren kannst. Stell unter Projektoptionen (Strg+Shift+F11) unter Formulare das Form2 so ein das es nicht automatisch erzeugt wird.

Im OnClick-Event des Preview-Buttons gibst du folgenden Code ein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Var
  Form: TForm2;
Begin
  Try
    // TForm2 manuel erstellen
    Form := TForm2.Create (Self);
    Try
      // Preview anzeigen;
      Form.Quickrep1.Preview;
    Finally
      // Form wieder freigeben
      Form.Free;
    End;
  Except
    { Fehler! }
  End;
End;

Der Code macht erzeugt selbst das Form und zeigt dann die Preview an. Anschließend wird das Form gelöscht. Ich denke so sollte es funktionieren.

Gruß
Tino
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Di 22.07.03 13:20 
Wahnsinn!!!! Es funktioniert!!!!! :D

Vielen, vielen Dank
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 22.07.03 13:28 
dragi hat folgendes geschrieben:
Vielen, vielen Dank

Bitte bitte! :-D

Denk aber daran das du auch den Code im OnClick-Event des Drucken-Buttons ändern musst!

Gruß
Tino
dragi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 88



BeitragVerfasst: Di 22.07.03 14:15 
Hab ich direkt geändert :)