如何從出貨單身的品名抓取產品基本檔的品號,單位,...顯示在單身欄位 |
尚未結案
|
trisakchen
一般會員 ![]() ![]() 發表:1 回覆:0 積分:0 註冊:2004-01-08 發送簡訊給我 |
背景: Database = Access
1. Deatil Dbgrid AdoTable is called dt2, it has column (
Part_name ,Part_code , unit, Tran_qty )
2. When user key in Part_name on the Dbgrid ,hope system can get Part_code , unit ,Inv_qty from
the elementay table (INVENTORY) and show on the Dbgrid Part_code ,Unit position.
4. The source program is as following Hope the professional friend can help me to solve the problem ,why the system will stop on line 14 and how to debug it ??
1 procedure Tfminvtran.dt2PART_NAMEValidate(Sender: TField);
2 var qrygetpart:tadoquery ;
3 begin
4 inherited;
5 with fminvtran do
6 begin
7 qrygetpart := tadoquery.Create(fminvtran);
8 qrygetpart.Close;
9 qrygetpart.SQL.Clear;
10 qrygetpart.Connection := dm.con1;
11 qrygetpart.SQL.Add('select part_name,part_code, unit ,inv_qty from inventory ');
12 qrygetpart.SQL.Add(' where part_name = ' ) ;
13 qrygetpart.SQL.Add( ' ''' dt2.FieldByName('part_name').AsString ''' '); ///// system stop on here
14 qrygetpart.Close;
15 try
16 qrygetpart.Open;
17 if qrygetpart.RecordCount = 1 then begin
18 dt2.FieldByName('part_code').AsString :=
19 qrygetpart.Fields[1].AsString;
20 dt2.FieldByName('unit').AsString :=
21 qrygetpart.Fields[2].AsString;
22 end;
23 finally
24 qrygetpart.Close;
25 qrygetpart.Free;
26 end;
27 end;
|
yachanga
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:24 回覆:335 積分:296 註冊:2003-09-27 發送簡訊給我 |
Hi
Please see the red parts and try it.
Hope it can be helpful for you .
引言: 背景: Database = Access 1. Deatil Dbgrid AdoTable is called dt2, it has column ( Part_name ,Part_code , unit, Tran_qty ) 2. When user key in Part_name on the Dbgrid ,hope system can get Part_code , unit ,Inv_qty from the elementay table (INVENTORY) and show on the Dbgrid Part_code ,Unit position. 4. The source program is as following Hope the professional friend can help me to solve the problem ,why the system will stop on line 14 and how to debug it ?? 1 procedure Tfminvtran.dt2PART_NAMEValidate(Sender: TField); 2 var qrygetpart:tadoquery ; 3 begin 4 inherited; 5 with fminvtran do 6 begin 7 qrygetpart := tadoquery.Create(fminvtran); 8 qrygetpart.Close; 9 qrygetpart.SQL.Clear; 10 qrygetpart.Connection := dm.con1; 11 qrygetpart.SQL.Add('select part_name,part_code, unit ,inv_qty from inventory '); 12 qrygetpart.SQL.Add(' where part_name = ''' dt2.FieldByName('part_name').AsString '''') ; 13 showmessage(qrygetpart.SQL.text); //try it and then you will see the SQL text 14 qrygetpart.Close; 15 try 16 qrygetpart.Open; 17 if qrygetpart.RecordCount = 1 then begin 18 dt2.FieldByName('part_code').AsString := 19 qrygetpart.Fields[1].AsString; 20 dt2.FieldByName('unit').AsString := 21 qrygetpart.Fields[2].AsString; 22 end; 23 finally 24 qrygetpart.Close; 25 qrygetpart.Free; 26 end; 27 end;~悠遊法國號~ |
deity
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:90 回覆:876 積分:678 註冊:2003-05-09 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |