以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  空值不保存  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=12265)

--  作者:明丰
--  发布时间:2011/8/27 17:35:00
--  空值不保存

 


If e.DataRow.IsNull("基本单位") Then \'基本单位为空时不能保存
Tables("货品资料").filter = "[基本单位] Is Null"
    messagebox.show("基本单位不能为空")
    e.Cancel = True \'
End If

选择其它数据表前执行上面代码,请问如何设置?


--  作者:明丰
--  发布时间:2011/8/27 19:35:00
--  

解决了.

\'项目事件MainTableChanging
If e.NewTableName <> "货品资料" AndAlso e.OldTableName = "货品资料" Then
Dim dr As DataRow
    dr = DataTables("货品资料").Find("[基本单位] Is Null")
    If dr IsNot Nothing Then \'
    e.Cancel = True
    Tables("货品资料").filter = "[基本单位] Is Null"
    messagebox.show("基本单位不能为空")
End If
End If

 

这样能避免多个表同时出现列空值不能保存需要每个表检查的情况.

[此贴子已经被作者于2011-8-27 20:57:02编辑过]