We help IT Professionals succeed at work.

Listbox from Table

kelsoR asked
Last Modified: 2012-02-13
Hi all,

I get a CSV file sent to me from various Clients on a monthly basic.
I then import this file as a Table object.

The problem is that each Clients file has diffrent field/column names - all code driven.
Eg: 1001 mean Group 1 with Catogery 001
There could be hunderds of codes but because they all use the same format (the 1st digit being the identifier) I need to group them accordingly on a Form or Report.

So creating a Listbox and setting the Row Source Type to "Field List" will give me all the fields names but that is not what I need. I need a Listbox for each of the 6 or so Groups.
So all field names starting with a '1' must be listed in a seperate Listbox named Group1.
The same goes for the other groups. All must feed off the same initial table containing all the field names but seperated by group.

The second thing I need to do it to also show the value (per staff member) contained in the field by group's catogery.

So the Main Form will be bound to a Staff List. And each Staff members will have diffrent catogeries and values.
So if I'm on Staff members 145, I should be able to see the 6 or so Listboxes containing the diffrent field name per group and then next to it the values for those fields.

1001 = $100        2006 = $400
1002 = $50          2018 = $500

Hope this makes sense.
PS: I attached a sample of a typical file I'm getting.

Any ideas anyone?
Watch Question

Top Expert 2009

After importing the CSV into a master table, you could make queries filtering the data in the master table by the first character in the field name, and use those queries as row sources for the different listboxes.  You could also alias the field names as needed in these queries, or make totals queries based on them to get totals or other calculations as needed.


Thanks Helen, but I'm batteling with step one - and that is to build a table containing all the field names of the master table. Else - how do I run the query on the 1st char without having the field name in a table.
From there I should be able to move in the direction you suggest yes.


I found this code which works 100% for the "Group1" but puts the same data in "Group2".
So somewhere I'm missing a "requery" command or something to clear it.

Dim rs As DAO.Recordset
Dim fld As DAO.Field
Dim strSQL As String
Dim strMsg As String
Dim strStart As String
strSQL = "Select * from WGEXHR"

Set rs = CurrentDb.OpenRecordset(strSQL)

For Each fld In rs.Fields
If Left(fld.Name, 1) = "1" Then strMsg = strMsg & fld.Name & ";"

strMsg = Left(strMsg, Len(strMsg) - 1)

Me.List1.RowSource = strMsg
Me.List1.RowSourceType = "value list"

For Each fld In rs.Fields
If Left(fld.Name, 1) = "2" Then strMsg = strMsg & fld.Name & ";"

strMsg = Left(strMsg, Len(strMsg) - 1)

Me.List2.RowSource = strMsg
Me.List2.RowSourceType = "value list"

Open in new window


Ahh - I missed a

strMsg = ""

Between the 2 sections. Works 100% for both groups now.

Next step is to show the values for the spesific staff member as explained in the original post above.
This one is on us!
(Get your first solution completely free - no credit card required)


Not sure if this is allowed but I answered my own quetions after batteling for long on the net.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.