21楼正解。下面是我的一个实例,涉及的表比较多,只能给出部分代码,请参考。
一、表单load事件中,创建视图,设置属性。源表有两个,dmxm和jkff&gcXuan,在视图中所作修改,发送更新后,会反应到这两个源表中。
Create View dingzhong&gcXuan As ;
SELECT Dmxm.d1 as d1, Dmxm.d2, dmxm.d3, Jkff&gcXuan..dz, Jkff&gcXuan..dzjine, Jkff&gcXuan..dzyajin,;
Jkff&gcXuan..dzyshou, Jkff&gcXuan..dzsshou, Jkff&gcXuan..dza, Jkff&gcXuan..dzajine, Jkff&gcXuan..dzayajin,;
Jkff&gcXuan..dzayshou, Jkff&gcXuan..dzasshou, Jkff&gcXuan..dzqkuan, Jkff&gcXuan..tdz, Jkff&gcXuan..tdzjine,;
Jkff&gcXuan..tdzsshou, Jkff&gcXuan..tdzqkuan, Dmxm.dz&gcXuan., Jkff&gcXuan..syd1, Jkff&gcXuan..syd2, Jkff&gcXuan..syd3,;
Jkff&gcXuan..syd4, Jkff&gcXuan..py1, Jkff&gcXuan..py2, Jkff&gcXuan..py3, Jkff&gcXuan..py4, Jkff&gcXuan..py5, Jkff&gcXuan..py6,;
Jkff&gcXuan..py7, Jkff&gcXuan..py8, Jkff&gcXuan..py9, Jkff&gcXuan..py10, Jkff&gcXuan..dzheji,Jkff&gcXuan..sydkuan,Jkff&gcXuan..d1 as d1_b;
FROM ;
pfc!dmxm ;
LEFT Outer Join pfc!jkff&gcXuan ;
ON
Dmxm.d1 = Jkff&gcXuan..d1;
ORDER By Dmxm.d1
DBSetProp('dingzhong&gcXuan',"View","SendUpdates",.T.)
DBSetProp('dingzhong&gcXuan',"View","BatchUpdateCount",1)
DBSetProp('dingzhong&gcXuan',"View","CompareMemo",.T.)
DBSetProp('dingzhong&gcXuan',"View","FetchAsNeeded",.F.)
DBSetProp('dingzhong&gcXuan',"View","FetchMemo",.T.)
DBSetProp('dingzhong&gcXuan',"View","FetchSize",100)
DBSetProp('dingzhong&gcXuan',"View","MaxRecords",-1)
DBSetProp('dingzhong&gcXuan',"View","Prepared",.F.)
DBSetProp('dingzhong&gcXuan',"View","UpdateType",1)
DBSetProp('dingzhong&gcXuan',"View","UseMemoSize",255)
DBSetProp('dingzhong&gcXuan',"View","Tables","pfc!jkff&gcXuan,pfc!dmxm")
DBSetProp('dingzhong&gcXuan',"View","WhereType",3)
DBSetProp('dingzhong&gcXuan.'+".d1","Field","DataType","C(8)")
DBSetProp('dingzhong&gcXuan.'+".d1","Field","UpdateName","pfc!dmxm.d1")
DBSetProp('dingzhong&gcXuan.'+".d1","Field","KeyField",.T.)
DBSetProp('dingzhong&gcXuan.'+".d1","Field","Updatable",.F.)
DBSetProp('dingzhong&gcXuan.'+".d2","Field","DataType","C(10)")
DBSetProp('dingzhong&gcXuan.'+".d2","Field","UpdateName","pfc!dmxm.d2")
DBSetProp('dingzhong&gcXuan.'+".d2","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".d2","Field","Updatable",.F.)
DBSetProp('dingzhong&gcXuan.'+".d3","Field","DataType","L")
DBSetProp('dingzhong&gcXuan.'+".d3","Field","UpdateName","pfc!dmxm.d3")
DBSetProp('dingzhong&gcXuan.'+".d3","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".d3","Field","Updatable",.F.)
DBSetProp('dingzhong&gcXuan.'+".dz","Field","DataType","N(8,2)")
DBSetProp('dingzhong&gcXuan.'+".dz","Field","UpdateName","pfc!jkff&gcXuan..dz")
DBSetProp('dingzhong&gcXuan.'+".dz","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dz","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzjine","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzjine","Field","UpdateName","pfc!jkff&gcXuan..dzjine")
DBSetProp('dingzhong&gcXuan.'+".dzjine","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzjine","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzyajin","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzyajin","Field","UpdateName","pfc!jkff&gcXuan..dzyajin")
DBSetProp('dingzhong&gcXuan.'+".dzyajin","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzyajin","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzyshou","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzyshou","Field","UpdateName","pfc!jkff&gcXuan..dzyshou")
DBSetProp('dingzhong&gcXuan.'+".dzyshou","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzyshou","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzsshou","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzsshou","Field","UpdateName","pfc!jkff&gcXuan..dzsshou")
DBSetProp('dingzhong&gcXuan.'+".dzsshou","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzsshou","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dza","Field","DataType","N(8,2)")
DBSetProp('dingzhong&gcXuan.'+".dza","Field","UpdateName","pfc!jkff&gcXuan..dza")
DBSetProp('dingzhong&gcXuan.'+".dza","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dza","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzajine","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzajine","Field","UpdateName","pfc!jkff&gcXuan..dzajine")
DBSetProp('dingzhong&gcXuan.'+".dzajine","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzajine","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzayajin","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzayajin","Field","UpdateName","pfc!jkff&gcXuan..dzayajin")
DBSetProp('dingzhong&gcXuan.'+".dzayajin","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzayajin","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzayshou","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzayshou","Field","UpdateName","pfc!jkff&gcXuan..dzayshou")
DBSetProp('dingzhong&gcXuan.'+".dzayshou","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzayshou","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzasshou","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzasshou","Field","UpdateName","pfc!jkff&gcXuan..dzasshou")
DBSetProp('dingzhong&gcXuan.'+".dzasshou","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzasshou","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzqkuan","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dzqkuan","Field","UpdateName","pfc!jkff&gcXuan..dzqkuan")
DBSetProp('dingzhong&gcXuan.'+".dzqkuan","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzqkuan","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".tdz","Field","DataType","N(8,2)")
DBSetProp('dingzhong&gcXuan.'+".tdz","Field","UpdateName","pfc!jkff&gcXuan..tdz")
DBSetProp('dingzhong&gcXuan.'+".tdz","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".tdz","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".tdzjine","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".tdzjine","Field","UpdateName","pfc!jkff&gcXuan..tdzjine")
DBSetProp('dingzhong&gcXuan.'+".tdzjine","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".tdzjine","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".tdzsshou","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".tdzsshou","Field","UpdateName","pfc!jkff&gcXuan..tdzsshou")
DBSetProp('dingzhong&gcXuan.'+".tdzsshou","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".tdzsshou","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".tdzqkuan","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".tdzqkuan","Field","UpdateName","pfc!jkff&gcXuan..tdzqkuan")
DBSetProp('dingzhong&gcXuan.'+".tdzqkuan","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".tdzqkuan","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dz&gcXuan","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".dz&gcXuan","Field","UpdateName","pfc!dmxm.dz&gcXuan")
DBSetProp('dingzhong&gcXuan.'+".dz&gcXuan","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dz&gcXuan","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".syd1","Field","DataType","I")
DBSetProp('dingzhong&gcXuan.'+".syd1","Field","UpdateName","pfc!jkff&gcXuan..syd1")
DBSetProp('dingzhong&gcXuan.'+".syd1","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".syd1","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".syd2","Field","DataType","I")
DBSetProp('dingzhong&gcXuan.'+".syd2","Field","UpdateName","pfc!jkff&gcXuan..syd2")
DBSetProp('dingzhong&gcXuan.'+".syd2","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".syd2","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".syd3","Field","DataType","I")
DBSetProp('dingzhong&gcXuan.'+".syd3","Field","UpdateName","pfc!jkff&gcXuan..syd3")
DBSetProp('dingzhong&gcXuan.'+".syd3","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".syd3","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".syd4","Field","DataType","I")
DBSetProp('dingzhong&gcXuan.'+".syd4","Field","UpdateName","pfc!jkff&gcXuan..syd4")
DBSetProp('dingzhong&gcXuan.'+".syd4","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".syd4","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py1","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py1","Field","UpdateName","pfc!jkff&gcXuan..py1")
DBSetProp('dingzhong&gcXuan.'+".py1","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py1","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py2","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py2","Field","UpdateName","pfc!jkff&gcXuan..py2")
DBSetProp('dingzhong&gcXuan.'+".py2","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py2","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py3","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py3","Field","UpdateName","pfc!jkff&gcXuan..py3")
DBSetProp('dingzhong&gcXuan.'+".py3","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py3","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py4","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py4","Field","UpdateName","pfc!jkff&gcXuan..py4")
DBSetProp('dingzhong&gcXuan.'+".py4","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py4","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py5","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py5","Field","UpdateName","pfc!jkff&gcXuan..py5")
DBSetProp('dingzhong&gcXuan.'+".py5","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py5","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py6","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py6","Field","UpdateName","pfc!jkff&gcXuan..py6")
DBSetProp('dingzhong&gcXuan.'+".py6","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py6","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py7","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py7","Field","UpdateName","pfc!jkff&gcXuan..py7")
DBSetProp('dingzhong&gcXuan.'+".py7","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py7","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py8","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py8","Field","UpdateName","pfc!jkff&gcXuan..py8")
DBSetProp('dingzhong&gcXuan.'+".py8","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py8","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py9","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py9","Field","UpdateName","pfc!jkff&gcXuan..py9")
DBSetProp('dingzhong&gcXuan.'+".py9","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py9","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".py10","Field","DataType","N(7,2)")
DBSetProp('dingzhong&gcXuan.'+".py10","Field","UpdateName","pfc!jkff&gcXuan..py10")
DBSetProp('dingzhong&gcXuan.'+".py10","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".py10","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".dzheji","Field","DataType","N(8,2)")
DBSetProp('dingzhong&gcXuan.'+".dzheji","Field","UpdateName","pfc!jkff&gcXuan..dzheji")
DBSetProp('dingzhong&gcXuan.'+".dzheji","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".dzheji","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".sydkuan","Field","DataType","N(10,2)")
DBSetProp('dingzhong&gcXuan.'+".sydkuan","Field","UpdateName","pfc!jkff&gcXuan..sydkuan")
DBSetProp('dingzhong&gcXuan.'+".sydkuan","Field","KeyField",.F.)
DBSetProp('dingzhong&gcXuan.'+".sydkuan","Field","Updatable",.T.)
DBSetProp('dingzhong&gcXuan.'+".d1_b","Field","DataType","C(8)")
DBSetProp('dingzhong&gcXuan.'+".d1_b","Field","UpdateName","pfc!jkff&gcXuan..d1")
DBSetProp('dingzhong&gcXuan.'+".d1_b","Field","KeyField",.T.)
DBSetProp('dingzhong&gcXuan.'+".d1_b","Field","Updatable",.t.)
Select 0
Use dingzhong&gcXuan
Set Multilocks On
=CursorSetProp('buffering',5)
二、保存按钮的代码
Select dingzhong&gcXuan
=Tableupdate(2,.T.)
三、表单queryunload
Local lnAnswer,lcmodified
Thisform.lxiugai=.F.
Select dingzhong&gcXuan
Scan
lcmodified=Getfldstate(-1)
If '2'$lcmodified Or '3'$lcmodified Or '4'$lcmodified
Thisform.lxiugai=.T.
Exit
Endif
Endscan
If Thisform.lxiugai=.T.
lnAnswer=Messagebox('当前表数据已被修改,是否保存?',3+32+512,'系统提示')
Do Case
Case lnAnswer=6
Replace All dzheji With dz&gcXuan
=Tableupdate(2,.T.)
Select dmxm
Replace All dzheji With dz1+dz2+dz3+dz4
Thisform.Release
Case lnAnswer=7
=Tablerevert(.T.)
Thisform.Release
Case lnAnswer=2
Nodefault
Endcase
Else
Thisform.Release
=Tablerevert(.T.)
Endif
四、退出按钮。因为要执行queryunload 事件,所以就不能Thisform.Release了。
ThisForm.QueryUnload