第一次操作报表可以正常显示,,进行另一次选择操作的时候,就没有数据显示出来了,怎么回事?在线等待!!!!急(50分)

  • 主题发起人 主题发起人 huantengteng
  • 开始时间 开始时间
H

huantengteng

Unregistered / Unconfirmed
GUEST, unregistred user!
用Hegebiaozhun上的RadioButton来决定Hegebiaozhun上的ADOQuery执行什么操作语句--查询那个表,然后将结果显示到ReportHege上,但是第一次操作RadioButton时,可以正常显示,,关闭预览,返回到Hegebiaozhun,在进行另一次选择操作的时候,就没有数据显示出来了,怎么回事?在线等待!!!!急


unit Hegebiaozhun;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ExtCtrls, Db, ADODB;

type
THege = class(TForm)
PageControl1: TPageControl;
Hegenan: TTabSheet;
Hegenv: TTabSheet;
RadioGroup1: TRadioGroup;
ADOConnectionHG: TADOConnection;
ADOQueryHG1: TADOQuery;
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
jieEdit1: TEdit;
Label3: TLabel;
Label4: TLabel;
departEdit1: TEdit;
Label5: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Hege: THege;

implementation

{$R *.DFM}
uses
ReportHege;

procedure THege.FormCreate(Sender: TObject);
begin
RadioGroup1.ItemIndex:=0;
end;

procedure THege.Button1Click(Sender: TObject);
begin

adoqueryHG1.close;
adoqueryHG1.sql.clear;

if RadioGroup1.ItemIndex=0 then
adoqueryHG1.sql.add('select * from 大一男 where 级别='''+jieEdit1.Text+''' and 系别='''+departEdit1.Text+'''');
if RadioGroup1.ItemIndex=1 then
adoqueryHG1.sql.add('select * from 大二男');
if RadioGroup1.ItemIndex=2 then
adoqueryHG1.sql.add('select * from 大三男');
if RadioGroup1.ItemIndex=3 then
adoqueryHG1.sql.add('select * from 大四男');

adoqueryHG1.open;


end;


procedure THege.Button2Click(Sender: TObject);

var HegeReportnan:THegeReportnan;

begin

HegeReportnan:=THegeReportnan.create(self);

Hege:=THege.Create(application);
if RadioGroup1.ItemIndex=0
then HegeReportnan.QRLabel1.caption:='一年级' ;
if RadioGroup1.ItemIndex=1
then HegeReportnan.QRLabel1.caption:='二年级' ;
if RadioGroup1.ItemIndex=2
then HegeReportnan.QRLabel1.caption:='三年级' ;
if RadioGroup1.ItemIndex=3
then HegeReportnan.QRLabel1.caption:='四年级' ;

HegeReportnan.QuickRepHGnan.Preview;
HegeReportnan.free;
end;

end.
--------------------------------------------------------
unit ReportHege;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, ExtCtrls;

type
THegeReportnan = class(TForm)
QuickRepHGnan: TQuickRep;
DetailBand1: TQRBand;
ID: TQRDBText;
TitleBand1: TQRBand;
QRLabel1: TQRLabel;
Name: TQRDBText;
Sex: TQRDBText;
DB1: TQRDBText;
DB2: TQRDBText;
TY1: TQRDBText;
TY2: TQRDBText;
S1: TQRDBText;
S2: TQRDBText;
S3: TQRDBText;
S4: TQRDBText;
K1: TQRDBText;
K2: TQRDBText;
X1: TQRDBText;
X2: TQRDBText;
J1: TQRDBText;
J2: TQRDBText;
TY3: TQRDBText;
Z: TQRDBText;
Fen: TQRDBText;
Ban: TQRDBText;
procedure FormCreate(Sender: TObject);


private
{ Private declarations }
public
{ Public declarations }
end;

var
HegeReportnan: THegeReportnan;

implementation

{$R *.DFM}
uses
Hegebiaozhun;

procedure THegeReportnan.FormCreate(Sender: TObject);

begin

QuickRepHGnan.Dataset:=Hege.adoQueryHG1;
ID.Dataset:=Hege.adoQueryHG1;
ID.Datafield:='学号';
Ban.Dataset:=Hege.adoQueryHG1;
Ban.Datafield:='班级';
Name.Dataset:=Hege.adoQueryHG1;
Name.Datafield:='姓名';
Sex.Dataset:=Hege.adoQueryHG1;
Sex.Datafield:='性别';


end;

end.



 
table.frist
 
procedure THege.Button2Click(Sender: TObject);

var HegeReportnan:THegeReportnan;

begin

HegeReportnan:=THegeReportnan.create(self);

Hege:=THege.Create(application);
if RadioGroup1.ItemIndex=0
then HegeReportnan.QRLabel1.caption:='一年级' ;
if RadioGroup1.ItemIndex=1
then HegeReportnan.QRLabel1.caption:='二年级' ;
if RadioGroup1.ItemIndex=2
then HegeReportnan.QRLabel1.caption:='三年级' ;
if RadioGroup1.ItemIndex=3
then HegeReportnan.QRLabel1.caption:='四年级' ;
adoQueryHG1.first; //加上这句
HegeReportnan.QuickRepHGnan.Preview;
HegeReportnan.free;
end;

end.
--------------------------------------------------------
 
可以不行呀
还是老样子
:(
 
要不你就作一个Button关闭在打开就好
你有一个贴子不是这么说的马?
 
多人接受答案了。
 
后退
顶部