0
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 = 行のプロパティの無効な使用

なんで?どうすれば解決できますか?

4

1 に答える 1

2

これを試すことができます:

If IsNull(recSet.Fields("Customer_name").Value) Then
    txtCustomer_name.Text = ""
Else
    txtCustomer_name.Text = recSet.Fields("Customer_name").Value
End If
于 2013-07-31T12:19:24.210 に答える