List Fields Name in combo box

  • Thread starter Thread starter LeeTV
  • Start date Start date
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
 
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
 
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.
 
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>
 
Back
Top