If  Me.Adodc1.Recordset.Fields("comments") = Null Then
         MsgBox "ddd"
         Me.TxtComments.Text = " "
         Else
         Me.TxtComments.Text = Me.Adodc1.Recordset.Fields("comments")
         End If为什么comments这个值为NULL的时候不走MsgBox "ddd"
         Me.TxtComments.Text = " "
这段代码,而直接走了Else了  下面是这个程序的简单的代码!!请各位多多帮忙谢谢了
If Me.Option1.Value = True Then
        Me.Adodc1.RecordSource = "select * from Person where id ='" & Trim(Me.Combo1.Text) & "'"
        Me.Adodc1.Refresh
        
         Me.TxtId.Text = Me.Adodc1.Recordset.Fields("id")
         Me.TxtName.Text = Me.Adodc1.Recordset.Fields("name")
         Me.CombSex.Text = Me.Adodc1.Recordset.Fields("sex")
         Me.TxtBirth.Text = Me.Adodc1.Recordset.Fields("birth")
         Me.ComPolitical.Text = Me.Adodc1.Recordset.Fields("political")
         Me.CombHeadship.Text = Me.Adodc1.Recordset.Fields("headship")
         Me.CombDuty.Text = Me.Adodc1.Recordset.Fields("duty")
         Me.CombOwner_id.Text = Me.Adodc1.Recordset.Fields("dept_id")
         Me.TxtWork_date.Text = Me.Adodc1.Recordset.Fields("work_date")
         Me.Text6.Text = Me.Adodc1.Recordset.Fields("tel")
         Me.Text15.Text = Me.Adodc1.Recordset.Fields("mobile")
         Me.TxtP_id.Text = Me.Adodc1.Recordset.Fields("p_id")
         Me.TxtE_mail.Text = Me.Adodc1.Recordset.Fields("e_mail")
         Me.TxtAddr.Text = Me.Adodc1.Recordset.Fields("addr")
         If Not Me.Adodc1.Recordset.Fields("comments") = Null Then
         MsgBox "ddd"
         Me.TxtComments.Text = " "
         Else
         Me.TxtComments.Text = Me.Adodc1.Recordset.Fields("comments")
         End If
         
         
         
       
    End If

解决方案 »

  1.   

    If  Me.Adodc1.Recordset.Fields("comments") = Null Then 改成:
    If  IsNull(Me.Adodc1.Recordset.Fields("comments")) Then 
      

  2.   

    同上
    用IsNull函数来判断某个值是否是无效值
      

  3.   

    If  IsNull(Me.Adodc1.Recordset.Fields("comments")) = True Then
             MsgBox "ddd"
             Me.TxtComments.Text = " "
    Else
             Me.TxtComments.Text = Me.Adodc1.Recordset.Fields("comments")
    End If在VB里If...= Null是不行的,不过在REALbasic中If...=Nil到可以