-
Hi,
On my form I have:
Data1 control hooked up to an Access Database, a ComboBox control and a TextBox control
In that Database I have a table 'Prices-SoftDrinks' with 2 fields, Volume & Price:
Volume...Price
0.3L........0.75
0.5L........0.90
1L..........1.29
2L..........1.99
I read 'Volume' values in a ComboBox.
I want to be able to select one of the values from the ComboBox ('Volume' field) and get the corresponding price from 'Price' field from database. Then display the corresponding Price in a Text1 textbox.
I tried the following:
Data1.RecordSource = "prices-softdrinks"
Data1.Refresh
Data1.RecordSet.FindFirst "Volume = ComboBox.Text"
Text1.Text = Data1.Recordset.Fields("Price").Value
...but doesn't work, although the following works if I use '0.5L' instead of ComboBox.Text...
Data1.RecordSource = "prices-softdrinks"
Data1.Refresh
Data1.RecordSet.FindFirst "Volume = '0.5L'"
Text1.Text = Data1.Recordset.Fields("Price").Value
...however I don't want to hardwire the values, but select them from ComboBox
Please help!:)
-
Try:
Data1.RecordSource = "prices-softdrinks"
Data1.Refresh
Data1.RecordSet.FindFirst "Volume = '" & ComboBox.Text & "'"
Text1.Text = Data1.Recordset.Fields("Price").Value
-
Thank you Sebs, It works great!!!