Z
zyx1122
Unregistered / Unconfirmed
GUEST, unregistred user!
there are 2 form:Main and Sub
and a procdure named SetSQL in datamodule
////////////// Tdmclient::SetSQL ///////////////////////
Procdure TdmClient:SetSQL(strSQL : string)
begin
cdsMaster.close;
cdsMaster.CommandText := strSQL;
cdsMaster.open;
end;
///////////// TfrmMain::OnCreate //////////////////
Procdure TfrmMain::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from customer';
dmclient.SetSQL(strSQL);
end;
///////////// TfrmSub::OnCreate //////////////////
Procdure TfrmSub::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from orders';
dmclient.SetSQL(strSQL);
end;
And when I set the project's start form to frmMain
it can get customer's data.
When I set the project's start form to frmSub
it can get orders' data.
It's right.
// the problem is :
And now I set the project's start form to frmMain,
I add a command button named "OpenSubForm' in frmMain
and it's click event is
///////////// cmbOpenSubForm ////////////////////
Procdure TfrmMain:cmbOpenSubFormOnClick(...)
var
frmSub : TfrmSub;
begin
frmSub := TfrmSub.Create(self);
end
/////////////
When I click the command button,
the frmSub data is still customer,
not orders. Why?
I just have 25, It's a little pity.
and a procdure named SetSQL in datamodule
////////////// Tdmclient::SetSQL ///////////////////////
Procdure TdmClient:SetSQL(strSQL : string)
begin
cdsMaster.close;
cdsMaster.CommandText := strSQL;
cdsMaster.open;
end;
///////////// TfrmMain::OnCreate //////////////////
Procdure TfrmMain::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from customer';
dmclient.SetSQL(strSQL);
end;
///////////// TfrmSub::OnCreate //////////////////
Procdure TfrmSub::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from orders';
dmclient.SetSQL(strSQL);
end;
And when I set the project's start form to frmMain
it can get customer's data.
When I set the project's start form to frmSub
it can get orders' data.
It's right.
// the problem is :
And now I set the project's start form to frmMain,
I add a command button named "OpenSubForm' in frmMain
and it's click event is
///////////// cmbOpenSubForm ////////////////////
Procdure TfrmMain:cmbOpenSubFormOnClick(...)
var
frmSub : TfrmSub;
begin
frmSub := TfrmSub.Create(self);
end
/////////////
When I click the command button,
the frmSub data is still customer,
not orders. Why?
I just have 25, It's a little pity.