Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Chicago
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    combo box/macro combination on form (xp)

    Hello

    How can set up a combo box on a form so each item - if chosen from the drop-down list - triggers a different query whose recordset is then shown on the form?
    The combo box will have a list of three things to choose from.

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: combo box/macro combination on form (xp)

    Let's assume the combo is named cboRS. In it's after update event you need code like this:

    Select case cboRS.ListIndex
    Case 0
    me.recordsource = "......"
    Case 1
    me.recordsource = "......."
    .
    . etc.
    .
    End Select
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: combo box/macro combination on form (xp)

    Create a small table with two fields: QueryName and DisplayText (both text fields); the first is the primary key:

    <table border=1><td align=center>QueryName</td><td align=center>DisplayText</td><td>qryCustUS</td><td>US Customers</td><td>qryCustAsia</td><td>Asia Customers</td><td>qryCustEur</td><td>European Customers</td></table>
    Set the Row Source property of the combo box to the name of this table, the Column Count property to 2, and the Column Widths property to 0";1".

    Create an After Update event procedure for the combo box:

    Private Sub cboQueries_AfterUpdate
    If Not IsNull(Me.cboQueries) Then
    Me.RecordSource = Me.cboQueries
    Me.Requery
    End If
    End Sub

Posting Permissions

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