以文本方式查看主题

-  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=128620)

--  作者:湛江智
--  发布时间:2018/12/11 18:12:00
--  [求助]不能录入小于原值
 不能录入小于原值,下面的代码无效,怎么修改呢?
第一列是整数列
DataColChanging

 If e.DataRow("第一列").NewValue <e.DataRow("第一列").oldValue  Then
        MessageBox.Show("不能录入小于原值!")
            e.Cancel = True \'则取消编辑
End If


[此贴子已经被作者于2018/12/11 18:17:26编辑过]

--  作者:有点甜
--  发布时间:2018/12/11 18:14:00
--  

参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=128597&skin=0

 


--  作者:湛江智
--  发布时间:2018/12/11 18:18:00
--  回复:(有点甜)参考 http://www.foxtable....
如果第一列是日期列,录入的日期不能早于或晚于原日期呢?
--  作者:有点蓝
--  发布时间:2018/12/11 19:40:00
--  
用法完全一样,直接比较即可
--  作者:湛江智
--  发布时间:2018/12/20 16:43:00
--  回复:(有点蓝)用法完全一样,直接比较即可
 如果增加一个条件:设计任务要求_实际设计面积为空时,不可以录入100
下面代码怎么修改呢?

If e.DataCol.name = "进度" AndAlso e.DataRow.RowState <> DataRowState.Added Then  
    If Tables("表A").Current("设计任务要求_实际设计面积") Is Nothing Then
        If e.newvalue = 100 Then
            msgbox("实际设计面积不能为空!")
            e.cancel = True
        End If
    End If
End If
[此贴子已经被作者于2018/12/20 17:02:00编辑过]

--  作者:有点甜
--  发布时间:2018/12/20 17:26:00
--  
If e.DataCol.name = "进度" AndAlso e.DataRow.RowState <> DataRowState.Added Then  
    If e.datarow("设计任务要求_实际设计面积") = nothing Then
        If e.newvalue = 100 Then
            msgbox("实际设计面积不能为空!")
            e.cancel = True
        End If
    End If
End If

--  作者:湛江智
--  发布时间:2018/12/25 21:58:00
--  回复:(有点甜)If e.DataCol.name = "进度" AndAlso...
 下面代码怎么修改,整改下面2段代码呢?求助

项目为空时,进度输入100,提示:不能小于已完成的进度  再提示 项目不能为空!   ,想实现不提示:提示:不能小于已完成的进度

项目不为空时,进度输入100 失败!  提示:不能小于已完成的进度    想实现能输入100



If e.DataCol.name = "进度" AndAlso e.DataRow.RowState <> DataRowState.Added Then
    If e.DataRow.OriginalValue(e.DataCol.name) <> Nothing AndAlso e.newvalue < e.DataRow.OriginalValue(e.DataCol.name) Then
        msgbox("不能小于已完成的进度")
        e.cancel = True
    End If

    If e.DataRow("项目") = Nothing Then
        If e.newvalue = 100 Then
            msgbox("项目不能为空!")
            e.cancel = True
        End If
    End If
End If
[此贴子已经被作者于2018/12/25 22:02:07编辑过]

--  作者:有点蓝
--  发布时间:2018/12/25 22:18:00
--  
没看明白。到底是提示还是不提示?
--  作者:湛江智
--  发布时间:2018/12/25 22:30:00
--  回复:(有点蓝)没看明白。到底是提示还是不提示?
简单点说,就是项目列为空,进度不能输入100

进度输入的值只能输入比之前大的值

不满足上面条件时提示


[此贴子已经被作者于2018/12/25 22:40:46编辑过]

--  作者:有点蓝
--  发布时间:2018/12/25 22:53:00
--  
If e.DataCol.name = "进度" 
    If e.DataRow.isnull("项目") andalso e.newvalue = 100 Then
            msgbox("项目不能为空!")
            e.cancel = True
    elseIf e.DataRow.RowState <> DataRowState.Added andalso e.DataRow.OriginalValue(e.DataCol.name) <> Nothing AndAlso e.newvalue < e.DataRow.OriginalValue(e.DataCol.name) Then
        msgbox("不能小于已完成的进度")
        e.cancel = True
    End If
End If