Private Sub Form_Activate()
Dim st1 As String
'if txtmode 1 fetch record of id from database
If txtmode.Text = "1" Then
'SQL statement
openCon
st1 = "SELECT Customer_name, Address1, Address2, City, Contact FROM customer WHERE id=" & txtid.Text
recSet.Open st1, conn, adOpenDynamic, adLockOptimistic
recSet.MoveFirst
If recSet.Fields("Customer_name").Value <> vbNullString Then
txtCustomer_name = recSet.Fields("Customer_name").Value
Else
txtCustomer_name = ""
End If
当我运行程序时,出现错误:
编译器错误:在txtCustomer_name = line
上无效使用属性
为什么呢?我该如何解决呢?
答案 0 :(得分:2)
你可以试试这个:
If IsNull(recSet.Fields("Customer_name").Value) Then
txtCustomer_name.Text = ""
Else
txtCustomer_name.Text = recSet.Fields("Customer_name").Value
End If