Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blank Combo Boxes (2000)

    Hello Loungers

    I have a form with two Combo boxes and a List box on it. The Combos dictate what appears in the List box based on Document Type and Site Name.

    If a selection is made in the first Combo box the list box fills with documents of that type. If a selection is then made in the second Combo box the list box fill with details of documents according to the selected type, all ok so far.

    In the above scenario the first Combo still displays the results of the first selection. How do I code the first Combo to display nothing after making a second selection in the second Combo?

    I hope this makes sense! if not I'll delete some forms and attach the database.

    Regards

    Graeme

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

    Re: Blank Combo Boxes (2000)

    I assume you have code in the After Update event of the second combo box to update the list box. You can add a line to the After Update event procedure to clear the first combo box:

    Private Sub ComboBox2_AfterUpdate()
    ...
    ...
    Me.ComboBox1 = Null
    End Sub

    where ComboBox1 and ComboBox2 are the names of the combo boxes.

  3. #3
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Combo Boxes (2000)

    Surely it can't be that simple!!!

    I've just spent the last half hour looking at all the Combo properties.

    Regards

    Graeme

  4. #4
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Combo Boxes (2000)

    Ok done that, thanks

    Now how do I open a form to display specific data with the double click event of the List box? At the moment it works on a separate Command button but a double click would be classier.

    I spent some time reading up on and playing with the WHERE part of the List box Row source.

    Regards

    Graeme

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

    Re: Blank Combo Boxes (2000)

    You can use DoCmd.OpenForm with a WhereCondition argument based on the item selected in the list box. It would look like this:

    <code>Private Sub ListBox1_DblClick(Cancel As Integer)</code>
    <code> DoCmd.OpenForm FormName:="frmMyForm", WhereCondition:="[FieldName]=" & Me.ListBox1</code>
    <code>End Sub</code>

    where:
    ListBox1 is the name of the list box,
    frmMyForm is the name of the form to be opened,
    FieldName is the name of the field whose value you want to set from the list box.

    In this example, I have assumed that the field is numeric. If it is a text field, the value must be enclosed in quotes, one way to do this in code is to use Chr(34):

    <code>..., WhereCondition:="[FieldName]=" & Chr(34) & Me.ListBox1 & Chr(34)</code>

  6. #6
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Combo Boxes (2000)

    Pukka!

  7. #7
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Combo Boxes (2000)

    Why doesn't "Me.ListBox = Null" work in the form load event to clear the contents of the list box to display a blank list box when the form is opened?

    Does the list box work in a different way to the combo box in this respect?

    Again I've been playing with this for a while but not come up with a functioning answer!

    Regards

    Graeme

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

    Re: Blank Combo Boxes (2000)

    A combo box has a text box part. That is what you set to Null, not the list part. To clear the list part, use

    Me.ListBox.RowSource = ""

  9. #9
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Blank Combo Boxes (2000)

    Thanks

Posting Permissions

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