Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / March 2005

Tip: Looking for answers? Try searching our database.

How do you populate the column headers in an unbound Combobox?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vibhu - 10 Mar 2005 04:41 GMT
How do I populate the Column Headers in the drop-down section of a
multi-column combobox? This is the combobox used in Access 2000.  I
referenced the Microsoft Forms 2.0 Object Library to include it in my
VB app. I set the ColumnHeads property to True, but I can't assign a
value to each header unless it's bound (then it's automatically the
field name). I am not a fan of bound controls.

This very similar problem was posted in this very group about 4 years
back but the solution that is mentioned is not applicable it seems. Any
help will be helpful.
mattcannen - 22 Mar 2005 23:33 GMT
Try this I used a listbox but this should be the same.

Sub PopulateListFromRecordset(lstList As ListBox, rsRecordset As
ADODB.Recordset, intNumCols As Integer)

   Dim intCounter As Integer
   Dim strItem As String
   Dim strFill As String
strFill = "Column title1;Column Title2;"
   
   With lstList
      .RowSource = ""
      .ColumnCount = intNumCols
      .RowSourceType = "Value List"
      .ColumnHeads = True
      Me!Your combo/listbox name here.ColumnWidths = "3 cm; 1.8 cm;"
   End With
   'add all of the values in the recordset to the list box
           
   Do Until rsRecordset.EOF
    'for each item in the current record, build string
      For intCounter = 0 To intNumCols - 1
         strItem = strItem & rsRecordset(intCounter).Value & ";"
         strFill = strFill & rsRecordset(intCounter).Value & ";"
      Next intCounter
      lstList.AddItem (strItem)
      strItem = ""
      rsRecordset.MoveNext
   Loop
   
   Me.YourformName.RowSource = strFill
   Exit Sub

End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.