黎明最好看的演唱会:为什么判断是真,却不执行msgbox啊?

来源:百度文库 编辑:高考问答 时间:2024/04/27 19:43:07
If Me.Adodc1.Recordset.Fields("comments") = Null Then MsgBox "ddd" Else Me.TxtComments.Text = Me.Adodc1.Recordset.Fields("comments")
end if
为什么判断是真,却不执行msgbox啊?
就25分了 悬5分 呵呵 谢谢关照

可以用 If IsNull(Me.Adodc1.Recordset.Fields("comments")) Then MsgBox "ddd" 这样判断的话只有当comments字段为NULL时才为True,如果comments字段为空字符串""的话,条件不成立。

或者If Me.Adodc1.Recordset.Fields("comments")) & "" = "" Then MsgBox "ddd" 这样判断的话无论comments字段是NULL还是空字符串""条件头会成立。

不想挨揍的话,请改正格式!!
If Me.Adodc1.Recordset.Fields(\"comments\") = \"\" Then
MsgBox \"ddd\"
Else
Me.TxtComments.Text = me.Adodc1.Recordset.Fields(\"comments\")
end if

VB里,空字符串用\"\"表示

我觉得Null不能这么用。
你可以试试用
If Me.Adodc1.Recordset.Fields("comments") = ""
来进行判断。

应该是 If Me.Adodc1.Recordset.Fields("comments") == Null 吧