如果Rs中某些字段为空值的话,则以下程序会出错
Private Sub display()
    txtID = Rs("cCustomerID")
    txtName = Rs("vCustomerName")
    txtAccountNumber = Rs("cAccountNumber")
End Sub处理方法之一是
Private Sub display()
    txtID = Rs("cCustomerID")&""
    txtName = Rs("vCustomerName")&""
    txtAccountNumber = Rs("cAccountNumber")&""
End Sub请问这种方法好不好,或是对不对,有其他更好的方法吗?

解决方案 »

  1.   

    显示
      txtID= IIf(IsNull(Rs.Fields("cCustomerID")), "", Rs.Fields("cCustomerID"))写入数据库
      Rs.Fields("cCustomerID") = IIf(txtID.Text = "", Null, txtID.Text)
      

  2.   

    也可以这样:)
    txtID.Text = Rs("cCustomerID").Value & ""
      

  3.   

    If IsNull(Rs.Fields(cCustomerID).Value) Then
        txtID.Text =""
    Else
        txtID.Text = Rs.Fields(cCustomerID).Value
    End If