Combo box in form does not show existing value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tzoykas
    New Member
    • Apr 2013
    • 6

    Combo box in form does not show existing value

    Hello

    I have a database representing an inventory where objects are classified as normal or containers. Only containers can contain other objects and no object can be contained in more than one container. I use two tables, one listing the objects and the other table listing the relationships between objects and containers (which object is contained in which container).

    The second table uses a form in order to add data. The form has a combo box that lists objects that are not contained yet. It uses a query to do that. The query lists all the objects from the first table that are not contained in the second. After adding some data on that table I close the form. The next time I open it, I cannot see the values of the objects in the combo box, although the table contains them.

    I guess that the reason why the combo box does now show the values (to answer my own stupid question) is the fact that the query does not return values that are already there. So the question becomes, is there a workaround to circumvent that, when something actually exists in the field or should I add another box that will just display the value of the field of the current record?

    Thanks
    George

    P.S. Pardon the seemingly double post but I didn't realize that two questions don't fit in the same thread.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    You have accurately diagnosed the problem. There are several ways around this ranging from simple to complex. I'll give you the simple solution. The idea is generally the same for each solution, but the implementation of the idea is where the variety comes in.

    What I would do is to have one unbound combo box on your form that has the filter on it and then another combo box on the form that is bound to your field that has no filter in its row source, but have the control Locked. What you can then do is use the following code to move your selection from the unbound control to the bound control:
    Code:
    Me.BoundControlName = Me.UnboundControlName
    You can put this in the unbound control's after_update event or you can create a button that when clicked (on_Click event) will make the copy.

    Comment

    • tzoykas
      New Member
      • Apr 2013
      • 6

      #3
      That is great. Works like a charm

      Thanks again

      Comment

      Working...