Custom Queries for Combo and Listboxes

If I have a form with multiple combo boxes and a few list boxes, is there a way to create custom query sources for each one

It would appear that I have to create a query view for each control, even though only this one form will be using it. I'm thinking along the lines of how MS Access can have a custom SQL for each control.


Answer this question

Custom Queries for Combo and Listboxes

  • Sudheer_Dhulipalla_MSFT

    Thanks. That worked perfectly!

  • Reijo Tervonen

    protected Function GetTable(byval sql as string) as DataTable  
         using myconn as new OleDbConnection(myConString)  
              using myDa as new OleDbDataAdapter(sql,myConn)
                   Dim dt as new DataTable()
                   myDa.Fill(dt)
                   return dt
              end using     
         end using               
    end Function     

    usage:

    MyCombo.DataSource = GetTable("select items from mytable")               
    MyCombo.DisplayMember = "items"               
    MyCombo.ValueMember = "items"               

                   
                   
                   



  • Custom Queries for Combo and Listboxes