以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]怎样做一个输入检查  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=56685)

--  作者:lijin951
--  发布时间:2014/9/10 17:27:00
--  [求助]怎样做一个输入检查
我想做一个输入检查,用来校验,表中是否有值。比如表Z中有‘a’ ,‘b’ 两个字段我在保存这张表前需要检查里面是否有值,如果没值则返回不能保存
这张表作为窗口入库单的一个副本表名为t1,代码如下:

If DataTables("入库单_t1").DataRows.Count > 0 Then
    For Each r Row In Tables("入库单_t1")
        If r("a") = "" Then
            MessageBox.Show("明细中尚有a字段为填写","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Return
        End If
        If r("b") = "" Then
            MessageBox.Show("明细中尚有b字段未填写","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Return
        End If
    Next
Else
    MessageBox.Show("表Z无明细项不能保存","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If


If DataTables("表Z").HasChanges = True Then
    DataTables("表Z").Save
End If

这段代码执行不起,不知道错误在哪里

--  作者:Bin
--  发布时间:2014/9/10 17:30:00
--  
不用遍历. 直接在BeforSaveDataRow事件中判断就可以了

if e.datarow.isnull("A") orelse e.datarow.isnull("B") then
     messagebox.show("不能为空")
     e.cancel=true
end if