我试图在用户第一次登录时更新我的表tblusers中的一个字段。所以我使用的代码如下:
Dim db as DAO.Database
Dim MySQL As String
Set db= CurrentDb
If IsNull(firstlogindate) = True Then
MySQL = "update tblusers set firstlogindate = date() where empid = " & txtempid & ""
db.Execute MySQL, dbfailOnError
End If但之后什么都没发生。但是,当我尝试使用:If IsNull(firstlogindate) = True or firstlogindate = ""编写代码时,它就可以工作了,但是它会随时将字段更新为当前日期。这意味着首次登录日期会随时更新为当前日期。怎么啦?
发布于 2017-01-29 19:27:16
一定要在你的代码模块中使用:
Option Explicit我猜你在想这个:
MySQL = "update tblusers set firstlogindate = date() where empid = " & txtempid & " and firstlogindate is null"
db.Execute MySQL, dbfailOnErrorhttps://stackoverflow.com/questions/41919832
复制相似问题