還是unknow的問題 |
尚未結案
|
JamesLiang
初階會員 發表:54 回覆:78 積分:31 註冊:2003-02-13 發送簡訊給我 |
請教先進..我的表單設計為主表單是採用adoquery而副表單則是adotable
(因為主表單需作搜尋的動作),當主表單於insert的狀態時輸入新資料完成後
點選副表單輸入(此時主表單的狀態仍為dsinsert 而副表單的狀態此時為dsbrowse)這時我在副表單的dbgrid的欄位上輸入任一字元系統即出現unknow的訊息,我想此時應該還不是副表單出現錯誤才是,但一直找不到問題,是否請先進
代為解決?副程式如下;
uses VFF_MIS_Datamodule, Q_RDEV, Q_RDInvy, Q_RDOP, Q_RDProdName; {$R *.dfm}
var
R_ProdID : String;
Const
DatasetStates : array[TDatasetState] of string =
('Not Active','Browsing','Editing','Inserting','','','','','','','','','');
HelpTopicEdit = 2;
HelpTopicBrowse = 3; procedure TForm_RDMain.ActiveDSStateChange(Sender: TObject);
begin
with ActiveDS do
begin
if Dataset <> nil then
Statusbar1.Panels[0].Text := Format('[%S:%S]',[Dataset.Name,DatasetStates[State]]);
{if State in [dsEdit, dsInsert] then
begin
HelpContext := HelpTopicEdit;
Statusbar1.Panels[0].Text.color := clred;
end
else
begin
HelpContext := HelpTopicBrowse;
Statusbar1.Panels[0].text.color := clblue;
end; }
end;
end; procedure TForm_RDMain.FormCreate(Sender: TObject);
Var
I : Integer;
ProdName : String;
begin
ActiveDS.Dataset := DataModule1.AQ_RDMaster;
DataModule1.DS_RDMaster.DataSet := DataModule1.AQ_RDMaster;
With DataModule1.AQ_RDMaster do
begin
Close;
SQL.Clear;
SQLStr := 'Select * from A_RDMaster Order by' '''' 'CodeNo' '''';
SQL.Add(SQLStr);
Prepared;
Open;
end;
DataModule1.AT_RDProdName.Active := True;
with DataModule1.AT_RDProdName do
begin
For I :=0 to RecordCount - 1 do
begin
ProdName := Fields[1].AsString;
ComboBox1.Items.Add(ProdName);
next;
end;
end;
DataModule1.AT_RDDetail.Active := True;
DataModule1.AT_RDOPCondition.Active := True;
DataModule1.AT_RDEvaluation.Active := True;
end; procedure TForm_RDMain.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
DataModule1.AT_RDMaster.Active := False;
DataModule1.AT_RDProdName.Active := False;
DataModule1.AT_RDDetail.Active := False;
DataModule1.AT_RDOPCondition.Active := False;
DataModule1.AT_RDEvaluation.Active := False;
Action := caFree;
end; procedure TForm_RDMain.ComboBox1Click(Sender: TObject);
begin
C_KeyValue := ComboBox1.Text;
FindResult := DataModule1.AT_RDProdName.Lookup('ProductName',C_KeyValue,'ProductID');
If not varisnull(FindResult) then
R_ProdID := VartoStr(FindResult)
else
R_ProdID := '' ;
With DataModule1.AQ_RDMaster do
begin
Close;
SQL.Clear;
SQLStr := 'Select * from A_RDMaster where ProductID like ' '''' TrimRight(R_ProdID) '%' '''';
SQL.Add(SQLStr);
Prepared;
Open;
end;
end; procedure TForm_RDMain.DBGrid2_RDDetailEnter(Sender: TObject);
begin
{ActiveDS.Dataset := DataModule1.AT_RDDetail;
DBGrid2_RDDetail.Options := DBGrid2_RDDetail.Options [dgAlwaysShowSelection];}
end; procedure TForm_RDMain.DBGrid2_RDDetailDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.AT_RDDetail.FieldByName('AdjustWt').AsFloat <> 0 then
DBGrid2_RDDetail.Canvas.Font.Color := clred;
DBGrid2_RDDetail.DefaultDrawColumnCell(rect,datacol,column,[]);
end; procedure TForm_RDMain.DBEdit2_CodeNoEnter(Sender: TObject);
begin
with Datamodule1.AQ_RDMaster do
begin
if (state = dsInsert) then
DBEdit1_prodName.Text := R_ProdID;;
end
end; procedure TForm_RDMain.DBEdit2_CodeNoExit(Sender: TObject);
begin
DataModule1.AT_RDMaster.Active := True;
with Datamodule1.AQ_RDMaster do
begin
if (state = dsInsert) then
begin
C_KeyValue := '';
C_KeyValue := DBEdit2_CodeNo.Text;
FindResult := DataModule1.AT_RDMaster.Lookup('CodeNo',C_KeyValue,'CodeNo');
If not varisnull(FindResult) then
begin
ShowMessage('Duplicate Key, Tray Onec Again');
fieldbyname('CodeNo').FocusControl;
end;
end;
end;
end; procedure TForm_RDMain.DBGrid2_RDDetailEditButtonClick(Sender: TObject);
begin
{C_KeyValue := DBGrid2_RDDetail.Fields[0].Value;
With TQForm_RDInvy.Create(self) do
try
showmodal;
finally
free;
end; }
end;
|
JamesLiang
初階會員 發表:54 回覆:78 積分:31 註冊:2003-02-13 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |