以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]输入记录时,要求先输入字段A和字段B。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=70049)

--  作者:dogman
--  发布时间:2015/6/15 10:26:00
--  [求助]输入记录时,要求先输入字段A和字段B。
输入记录时,要求先输入字段A和字段B。即:输入字段A或输入字段B时无提示,输入其他字段时,如果字段A或字段B为空,则提示‘请先输入字段A和字段B’。并取消输入。

以下是我的代码:(在表的DataColChanging中)
If e.DataCol.Name = "第一列" OrElse e.DataCol.Name = "第二列" Then
Else
    If Trim(e.DataRow("第一列")) = "" OrElse Trim(e.DataRow("第二列")) = "" Then
        MessageBox.Show("请先输入第一列第二列!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = True
        Return
    End If
End If

请问以上代码对吗?是否要加Return?

--  作者:Bin
--  发布时间:2015/6/15 10:30:00
--  
不需要.而且最好用 ISNULL来判断是否为空 
If e.DataCol.Name = "第一列" OrElse e.DataCol.Name = "第二列" Then
Else
    If e.DataRow.isnull("第一列") OrElse e.DataRow.isnull("第二列") Then
        MessageBox.Show("请先输入第一列第二列!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = True
    End If
End If

--  作者:dogman
--  发布时间:2015/6/15 10:32:00
--  
谢谢!