Reputation: 388
I have a table products
with 6 columns including column PRICE. What i want to achive is this:
products
.Ex: Table Products
ProductName Price
Mango 12
Apple 15
Combo Box Values:
Mango
Apple
Combo box text box value:
Mango
PRICE text box value automatically be filled up with:
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
I'm trying this one all day but this doesn't work, how to correct this one?Really confused to this.
Upvotes: 1
Views: 1605
Reputation: 282
Try this one: This serrve as sample...Hope it helps
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
Upvotes: 2