ComboBox listing Columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query named "query1". I would like to create a combobox that will
list all the fields (columns) in "query1". Any ideas as to how to write a
query that will display all those fields (columns)??
 
I'm assuming you want to do this on a form as opposed to a table itself?

Create your combo box, its controlsource to Query1

Format the combobox as follows:

ColumnCount = Number of columns you are querying
ColumnWidths = 1cm,2cm,3cm,5cm and so on

NB: You can use 0cm if you need to hide some columns that may not be relevant.

Your BoundColumn should be, for example, the Primary Key - its easier to
leave that at column 1.

You can also change the LIstWidth to accommodate the column sizes you specify

Hope this helps
 
Ray,
Just include all the columns in your query, and set the NoOfColumns for the combo equal
to the number of those columns.
Set the ColumnWidths accordingly for each column in the query, and set the ListWidth to
the sum of the ColumnWidths.
Combo boxes are really meant for data selection, so making huge combos shouldn't
normally be necessary. They should only display enough relevant dat for the user to make
the proper value selectionselction... no more no less.
 
Sorry, was not specific. I DON'T want to see the values.....I DO want to see
the names (titles) of the columns themselves.
 
Ray,
I can't figure out why you would want to show empty columns in a combo, that
aren't of any real value in assisting the user to make the proper selection from the
combo.

But...
If you just want a header name for an empty column, use calculated fields in your
query,
on those columns that you just want a header on.

FirstHeader : "" SecondHeader : "" etc...

Make sure ColumnHeads is Yes.
 
Change the combo's RowSourceType to "Field List". Then set the
RowSource to "query1".

HTH,

KEvin
 
The solution is as follows

SELECT Mid([Expression],15,30) AS FieldName
FROM MSysQueries
WHERE (((MSysQueries.Attribute)=6) AND ((MSysQueries.ObjectId)=-2147483572));
 
Your suggestion worked just fine also. Thanks.

Kevin K. Sullivan said:
Change the combo's RowSourceType to "Field List". Then set the
RowSource to "query1".

HTH,

KEvin
 
Back
Top