Tables (not their fields) in a "dynamic" list box

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

Guest

1. I would like to have a form with a dropdown box listing all the tables in
my database.
2. When a new table is created, it will automatically be added to the list
box.
Are they both possible?
Thank you in advance for your help.
 
1. I would like to have a form with a dropdown box listing all the tables in
my database.
2. When a new table is created, it will automatically be added to the list
box.
Are they both possible?
Thank you in advance for your help.

As rowsource of a list box or combo box:

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

If you add additional tables, they will be added the next time the
form is opened. If you need to show the table immediately, you need to
requery the combo box:
Me![ComboName].requery
 
fredg said:
1. I would like to have a form with a dropdown box listing all the tables
in
my database.
2. When a new table is created, it will automatically be added to the
list
box.
Are they both possible?
Thank you in advance for your help.

As rowsource of a list box or combo box:

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


You might want to include types 4 (tables linked through ODBC) and 6 (other
linked tables) in that query as well.
 
Fred,
Thank you very much. It does exactly what I was looking for.


fredg said:
1. I would like to have a form with a dropdown box listing all the tables in
my database.
2. When a new table is created, it will automatically be added to the list
box.
Are they both possible?
Thank you in advance for your help.

As rowsource of a list box or combo box:

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

If you add additional tables, they will be added the next time the
form is opened. If you need to show the table immediately, you need to
requery the combo box:
Me![ComboName].requery
 
Thank you, Doug. Excellent suggestion.

Douglas J. Steele said:
fredg said:
1. I would like to have a form with a dropdown box listing all the tables
in
my database.
2. When a new table is created, it will automatically be added to the
list
box.
Are they both possible?
Thank you in advance for your help.

As rowsource of a list box or combo box:

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


You might want to include types 4 (tables linked through ODBC) and 6 (other
linked tables) in that query as well.
 

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

Back
Top