以文本方式查看主题

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

--  作者:裴保民
--  发布时间:2018/1/14 16:55:00
--  关于设置日期列的默认日期
怎样设置日期列的默认日期,在该列为空或新增列时将该列的日期起设置为指定日期:如1911年1月1日。该在哪个事件写呢?
--  作者:有点甜
--  发布时间:2018/1/14 17:47:00
--  

方法一:DataRowAdded事件

 

e.DataRow("日期") = date.Today

 

方法二:设置列属性 http://www.foxtable.com/webhelp/scr/1416.htm

 


--  作者:裴保民
--  发布时间:2018/1/14 20:36:00
--  
我在DataColChanged事件中编写如下代码:
Dim zcrq As Date= Cdate("1911-1-1")
If e.DataCol.name = "注册日期" Then
    If e.OldValue IsNot Nothing Then
        e.DataRow("注册日期") = zcrq 
       End If
End If
在 DataRowAdded事件中编写如下代码:运行后出现不能修改日期
Dim zcrq As Date= CDate("1911-1-1")
e.DataRow("注册日期") = zcrq

只要“注册日期”中的的数据发送改变后怎么立即就改为“1911-01-01”了,我想实现当打开此表或新增数据时,将“注册日期”字段为空的行设置成“1911-1-1”时中的的数据 但可以修改日期,但现在修改不了日期,一修改就改为1911-1-1了。不知道怎么设置?请甜老师帮忙
[此贴子已经被作者于2018/1/14 20:38:08编辑过]

--  作者:有点甜
--  发布时间:2018/1/14 20:39:00
--  
DataRowAdded事件

 

e.DataRow("注册日期") = Cdate("1911-1-1")

 

DataColChanged事件的代码,不需要写。或者写成

 

If e.DataCol.name = "注册日期" Then
    If e.newValue = Nothing Then
        Dim zcrq As Date= Cdate("1911-1-1")
        e.DataRow("注册日期") = zcrq 
       End If
End If
[此贴子已经被作者于2018/1/14 20:39:32编辑过]