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

    Re: Adding Recrods with a Combo box (Access All versio

    You could modify the row source of the combo box to include the current value, so that it can be displayed. This would work well in a single form (I use this technique in some of my databases) but not in a continuous form, since the combo box has the same row source for all records in a continuous form. As you move from record to record, only the value in the current record would be visible, those in the other records would still be invisible. You can get around this by putting the text box on top of the combo box. Make the text box slightly less wide, so as not to cover the dropdown arrow. See attached modified sample.
    Attached Files Attached Files

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

    Re: Adding Recrods with a Combo box (Access All versio

    In addition to Hans suggested method, which is also the way I handle this kind of thing, put the textbox in front of the combobox and use the Enter event of the Textbox to set the focus to the combobox. That will insure that if you do enter the textbox, you don't have to click the dropdown in order to get to the combobox.
    Charlotte

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Adding Recrods with a Combo box (Access All ve

    Thanks Hans

    With the changed row source, I get offered all ingredients for new records. not just the ones I haven't used.

    If I revert back to my original row source, and put the text box in front of the combo as you suggest, it works OK unless I put the cursor back in an old record. When I do this the combo hides the textbox and the so the existing words disappear.
    Attached Images Attached Images
    Regards
    John



  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Adding Records with a Combo box (Access All versio

    I often have a combo box used to add records in a continuous subform, with a hidden key field, where I might want to impose a restriction on values available for new records, that did not apply to older records when they were created.

    The problem with this is that the key field is no longer in the set of values for the combo, so the descritpive field displayed by the combo appears blank.

    Two examples: I am adding ingredients to a recipe, and I only want ot display ones that have not been used already for that recipe.
    I am assigning students to a class, and want to be restricted to current students, but when I look back at old classes their will be non-current students enrolled.

    The solution I use in this case is to shrink the combo box so it is no wider than the drop-down arrow, and display the descriptive field in a text box placed against the combo.

    This works, but it has two drawbacks: It looks different to a normal combo, and you need to use the mouse to choose from the list.

    My question is: has anyone got a better solution for this situation.

    I attach a sample to illustrate what I am talking about.
    Attached Files Attached Files
    Regards
    John



  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Adding Recrods with a Combo box (Access All ve

    I have played around with this a bit more, and find that by using the oncurrent event of the subform to change the row source of the combo between two queries I can get it to work perfectly.

    If you are in a new record, you only want to see the ones that haven't been used, but if you are in and old one, you want the current one and unused ones.

    <pre>Private Sub Form_Current()
    If IsNull(Me!IngredID) Then
    Me!IngredID.RowSource = "qry2"
    Else
    Me!IngredID.RowSource = "qry1"
    End If
    Me!IngredID.Requery
    End Sub
    </pre>


    I attach the modifed file.
    Attached Files Attached Files
    Regards
    John



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

    Re: Adding Recrods with a Combo box (Access All ve

    Good work! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

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