PRICEproducts
列を含む6列のテーブルがあります。私が達成したいのはこれです:
- コンボボックスから値を選択すると、次のテキストボックスであるPriceがデータベーステーブルから自動的に入力されます
products
。
例:テーブル製品
ProductName Price
Mango 12
Apple 15
コンボボックスの値:
Mango
Apple
コンボボックスのテキストボックスの値:
Mango
PRICEテキストボックスの値は自動的に次のように入力されます。
12
試したコード:
Private Sub Price()
Set Rs = New ADODB.Recordset
Set Cmd = New ADODB.Command
If txtProdName.txt Is Not Nothing Then
With Cmd
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = "SELECT price from products where productname=txtProdname.txt"
Set Rs = .Execute
End With
txtPrice = Rs.Fields
End If
End Sub
私はこれを一日中試していますが、これはうまくいきません、これを修正する方法は?本当にこれに混乱しています。