+ Reply to Thread
Results 1 to 5 of 5

How to show column headers in listbox from access database?

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    61

    How to show column headers in listbox from access database?

    Hi All,

    My form is connected to Access db and extracts only 8 column details from a big table and display in a listbox. Everything is working fine.
    How to show these particular column headers in listbox? Below is my code -

    Set rs = New ADODB.Recordset
    rs.Open "SELECT Emp_ID,Name,Facility_City_Role,BCM_Role,Designation,Cell_No,vNet,DL_Cog_All FROM DL_Mapping where Region in (" & Rglist & ") and Country in (" & CList & ") and City in (" & CityList & ") and Facility in (" & FacList & ") and Support_Function in (" & SFList & ")", Con, 1, 2
    i = 0

    Do While Not rs.EOF
    ListBox1.AddItem rs.Fields("Emp_ID")
    ListBox1.List(i, 1) = rs.Fields("Name")
    ListBox1.List(i, 2) = rs.Fields("Facility_City_Role")
    ListBox1.List(i, 3) = rs.Fields("BCM_Role")
    ListBox1.List(i, 4) = rs.Fields("Designation")
    ListBox1.List(i, 5) = rs.Fields("Cell_No")
    ListBox1.List(i, 6) = rs.Fields("vNet")
    ListBox1.List(i, 7) = rs.Fields("DL_Cog_All")
    rs.MoveNext
    i = i + 1

    Loop
    End If

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: How to show column headers in listbox from access database?

    Create a new table with the header names as the field records. Use that has your record source for the listbox.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: How to show column headers in listbox from access database?

    are you talking about a form in excel or in access? if it is in excel then you will have to add the column names as the first row of data-you cannot make them real column headers
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    09-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: How to show column headers in listbox from access database?

    Hi,

    Thanks for the reply.
    I am using vb - Alt F11 from Access 2007 and creating forms in this. Access is having a login page from which these vb forms will be called.

    currently i have to extract 13 columns(from revised database) and display in a multi col listbox. But listbox is restricted to 10 columns. I need to change to Listview. I know how to add this ctrl in VB+Excel. But i am unable to add the correct reference file to add listview control from access vb(Alt+F11). How to do this?

    Thanks
    Kiran

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: How to show column headers in listbox from access database?

    Here are some tutorials on combo boxes.

    Scroll down to the section on Combo Boxes.

    http://www.datapigtechnologies.com/AccessMain.htm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1