How do I list the column names only in a combo box

R

RSharp

I am trying to create a combo box that will list the column names (headings)
from a particular table. I've found ways to query the column names with other
products but have not discovered a way to do it with access yet.

I am trying to code a sql statement via VBA that will insert the column name
selected from the combo box.

ex. strSQL = "SELECT Column1, Column2, " & cmbColumn3 & ", Column4 FROM ..."

However, I would like to try to keep from having to type each column name
into the combo box list because new columns get added each year or so (not my
design) and I would have to go back and add new column names to the combo box
each time. So if I can create a query or something that I can use to populate
the combo box with the column names from the table, that would be ideal. Does
anyone know how I can pull this off?
 
K

Klatuu

That would be the Row Source Type property of the combo box.
There is the Value list - a list of hard coded values
The Table/Query - A table or query
The Field List - A list of fields from a table or query.
 
D

Douglas J. Steele

Set the combo's RowSourceType property to "Field List" (without the quotes)
and the RowSource to the table name.
 
R

RSharp

Thanks for the fast reply. It works the way I wanted it to. Don't know why I
didn't think of that myself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top