Results 1 to 3 of 3

Thread: Easy Database question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    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!
    Thanks

    Tomexx.

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Try:

    Data1.RecordSource = "prices-softdrinks"
    Data1.Refresh
    Data1.RecordSet.FindFirst "Volume = '" & ComboBox.Text & "'"
    Text1.Text = Data1.Recordset.Fields("Price").Value

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Thank you Sebs, It works great!!!
    Thanks

    Tomexx.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width