Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update Combo Box (2000)

    I have a combo box which is based on a query that pulls all the customers from a table. This combo box is bound by the ConID and has no control source. When a user select a value from a different combo box, I would like to update this combo box and requery it so only one record shows up and shows that record in the combo box. . For some reason, I cannot get the record to show in the combo box. ANy ideas would be great

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Combo Box (2000)

    The statements "This combo box is bound by the ConID" and "... and has no control source" seem contradictory.

    Why would you want a combo box to list only one record? That seems to go against the purpose of a combo box. Moreover, I don't understand exactly what you're saying, perhaps I'm confused about which combo box displays what. Could you try to explain?

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Combo Box (2000)

    The bound column is Row 0 of the row source (which is the CONID). The control source is left blank. A selection from the first combo box will filter what is show in the second combo box. In this case, the second combo box will only show one record. (Other times it will show many). After I make a change in the first combo box, I want to requery the second box (which is no prob), but if only one record is returned, I would like to have that one record show in the combo box instead of having the user select the single value from the box.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Combo Box (2000)

    You could do something like this:

    ...
    Me.ComboBox2.Requery
    If Me.ComboBox2.ListCount = 1 Then
    Me.ComboBox2 = Me.ComboBox2.ItemData(0)
    End If

    Replace ComboBox2 with the actual name.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Combo Box (2000)

    OK, to expand this further. Lets say that I have a list of customers in a combo box and I have a button on the form which allows the user to add a new customer on a seperate form. Once that customer is added, the new CONID is retrieved. How can I get the combo box on the original form to requery and default its values to the new customer added?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Update Combo Box (2000)

    You could use a public variable (declared in a standard module) to store the new CONID in.
    The first form should open the second form as a dialog form (DoCmd.OpenForm with acDialog as WindowMode argument), so that the code will pause until the second form has been closed. The code can then requery the combo box (so that the new CONID is in the list) and set its value to the value of the variable.

  7. #7
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update Combo Box (2000)

    Thanks Hans, I just had to change the Me.ComboBox2.ListCount = 2 because I have the headers showing

Posting Permissions

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