Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extract Multiple Fields From Combo Box (A2K)

    Preamble:

    When you create a combo box on form that is based on a query, you have the opportunity to look up values in that query. You can then select the field or fields that you wish to see when you get the dropdown. When you select that row, you can either store that value in a field in your database or use it later. It allows you to select ONE field only.

    Problem:

    I'm greedy. I want to store both fields into two appropriate fields in my database. And before all of the wise ones jump in and point out that that is an inappropriate manner in which to handle the situation, sorry, but in this case, because of other internal circumstances too lengthy and boring to explain, it is appropriate in this instance.

    Question:

    How do I get the two fields in from my dropdown? Thanks in advance for any help,
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Extract Multiple Fields From Combo Box (A2K)

    There is no automatic way, you have to write code to do it. You insist that it's appropriate but I have to point out that if you already have the ID value for the combobox in a field, there is no reason to store the other value in the same table since it can be easily looked up in the combobox source table/query. If you still insist on doing it, you will have to force a save on the record in the afterupdate of the combobox and then either execute SQL or open a recordset and modify the value in order to get the second field value in there. This isn't completely trivial code and you have no way to undo a record except by using code to overwrite the saved record with the previous values.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Extract Multiple Fields From Combo Box (A2K)

    Charlotte, thanks as always for your quick response. I'm sure the coding will not be trivial, but then neither, in my mind, are the reasons in this particular instance.
    Cheers,
    Andy

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Extract Multiple Fields From Combo Box (A2K)

    I may be way off base here but do you wish to save the value selected by the combo box and another of the combo box's fields?
    If so, in the AfterUpdate event of the ComboBox put:

    OtherField (control from table or query behind form) = YourComboBoxName.Column(n)

    where n points to the other field in the combobox bearing in mind these values start at zero.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Extract Multiple Fields From Combo Box (A2K)

    <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30> You're absolutely right, Pat. My only excuse is that I'm fumbling around in VB.Net at the moment where nothing in non-trivial, and my mind drifted away from Access. Thanks for picking up the dropped ball. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Charlotte

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Extract Multiple Fields From Combo Box (A2K)

    Pat,

    Bless and thank you for your sharp eyes. I think we should send Charlotte a couple of pints, which are never trivial, and help her get through the day. Thanks again to both of you,
    Cheers,
    Andy

Posting Permissions

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