Results 1 to 20 of 27

Thread: Solved: Populate a comboxbox and Listbox in a excel userform with an sql table data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    992
    Location
    From your first message...
    My first combo box is for region which needs to be populated from a sql table called Region_Mapping
    I assumed you want to search the database for UNIQUE list of Americas, yes?

    To get unique items from a Table, Use DISTINCT. This will get you the list without duplicates.

    and my first list box should be linked to the same sql table but it should populate the countries on the basis of the region which user will select in the combo box.
    Then, you use the value of the combobox to fill the listbox.

    So, Double click your combobox, then select the Exit event (upper right)
    Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    End Sub
    Inside this sub write another query to fill the listbox just like your example for the combobox.
    Last edited by Aussiebear; 04-19-2023 at 02:06 PM. Reason: Adjusted the code tags

    David


Posting Permissions

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