Reputation: 1
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
When I run my program, I get an error:
compiler error : invalid use of property on txtCustomer_name = line
Why? and how can I solve it ?
Upvotes: 0
Views: 71
Reputation: 4954
You can try this:
If IsNull(recSet.Fields("Customer_name").Value) Then
txtCustomer_name.Text = ""
Else
txtCustomer_name.Text = recSet.Fields("Customer_name").Value
End If
Upvotes: 2