List Fields Name in combo box

L

LeeTV

Hi
I am wanting to list the names of all tables in the current database and
then the names of all the fields for the previously selected table combo box,
but i am not sure how to do it.

basically, the process is as follows:
user selects the table in one combo box, then the second combobox refreshes
with the names of the fields in that table.
any help would be appreciated.

TIA
Lee
 
D

Douglas J. Steele

In the AfterUpdate event of the first combo box, put code like:

Private Sub Combo0_AfterUpdate()
Me.Combo2.RowSource = Me.Combo0
Me.Combo2.RowSourceType = "Field List"
End Su
 
F

fredg

Hi
I am wanting to list the names of all tables in the current database and
then the names of all the fields for the previously selected table combo box,
but i am not sure how to do it.

basically, the process is as follows:
user selects the table in one combo box, then the second combobox refreshes
with the names of the fields in that table.
any help would be appreciated.

TIA
Lee

Set the RowsourceType property of Combo2 to
FieldList
Leave the Rowsource property blank.

Set the Combo1 RowsourceType property to
Table/Query
Set the Rowsource to (all on one line):

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],4))<>"MSys") AND ((MSysObjects.Type)=1)) ORDER BY
MSysObjects.Name;

Code the Combo1 AfterUpdate event:

Me.Combo2.Rowsource = Me.Combo1


Selecting the table listed in Combo1 will fill Combo2 with taht tables
field names.
 
D

Douglas J. Steele

fredg said:
Hi
I am wanting to list the names of all tables in the current database and
then the names of all the fields for the previously selected table combo
box,
but i am not sure how to do it.

basically, the process is as follows:
user selects the table in one combo box, then the second combobox
refreshes
with the names of the fields in that table.
any help would be appreciated.

Set the RowsourceType property of Combo2 to
FieldList
Leave the Rowsource property blank.

Set the Combo1 RowsourceType property to
Table/Query
Set the Rowsource to (all on one line):

SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],4))<>"MSys") AND ((MSysObjects.Type)=1)) ORDER BY
MSysObjects.Name;

<picky>
You probably want

SELECT Name FROM MSysObjects WHERE
Left([Name],4)<>"MSys" AND Type IN (1, 4, 6)
ORDER BY Name;

1 is local tables, 4 is tables linked using ODBC, 6 is all other linked
tables.

</picky>
 

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