我有一个包含6列的表products
,其中包含 PRICE 列。我想要达到的目的是:
products
填充。Ex:表产品
ProductName Price
Mango 12
Apple 15
组合框值:
Mango
Apple
组合框文本框值:
Mango
PRICE 文本框值自动填充:
12
Tried Code:
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
我整天都在尝试这个,但这不起作用,如何纠正这个?真的很困惑。
答案 0 :(得分:2)
试试这个:这个serrve作为样本......希望它有所帮助
Private sub CboiPAQ_click()
Set rsiPAQs = New ADODB.Recordset
With rsiPAQs
.ActiveConnection = cnMHS
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockPessimistic
.Source = "SELECT location FROM iPAQs WHERE iPAQ=" & "'" & CboiPAQ.text & "'"
.Open
txtbox.text=rsiPAQs("location")
End With
End sub