Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill a Combo Box with the database objects

Access Howto:

Fill a Combo Box with the database objects

by  Tzokas  Posted    (Edited  )
I don't know if someone out there someday needed to do this, but because i did, this is the way:

Use the following SQL statements as Rowsource for the control depending on which object you want.

[color red]Tables[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name

[color red]Queries[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND (MSysObjects.Type)=5 ORDER BY MSysObjects.Name

[color red]Forms[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name

[color red]Reports[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name

[color red]Macros[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (MSysObjects.Type)= -32766 ORDER BY MSysObjects.Name

[color red]Modules[/color]
SELECT MSysObjects.Name FROM MsysObjects WHERE (MSysObjects.Type)= -32761 ORDER BY MSysObjects.Name


Notes:

1) In case of Tables we want NOT to appear the system tables that start with MSys
2) In case of Queries we exclude the "~" character because in other case the combo box shows objects starting with the "~" char.


Hope this was helpful
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top