How to add the names of tables to a combobox

A

Allen Browne

Try this query in the RowSource of your combo:
SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY MsysObjects.Name;

You can turn it into an Append query (Append on Query menu from query
design) if you wish.

Add Type 6 if you want the linked tables as well, type 4 for ODBC linked
tables.

If you prefer to use code, try:
If (tdf.Attributes And dbSystemObject) = 0 Then
 
S

Shadow

I'm trying to add the names of all tables in a database to a combobox.
But the names of system/hidden tables are added too.
this is what I did:

strFile = "C:\Program Files\Stock\OldData.mdb"
Set db = DBEngine.Workspaces(0).OpenDatabase(strFile)

For I = 0 To db.TableDefs.Count - 1
if not db.TableDefs(I).Attributes =dbHiddenObject then
cmbPastDataTables.AddItem db.TableDefs(I).Name
end if
Next I

How can I omit the system/hidden tables names to be added to the combobox?
Any kind of help is much appreciated.
 
S

Shadow

{If (tdf.Attributes And dbSystemObject) = 0 Then} did the magic.

thanks a million for your quick help

with regards
Ghalamkari



Allen Browne said:
Try this query in the RowSource of your combo:
SELECT MsysObjects.Name FROM MsysObjects
WHERE (([Type] = 1) AND ([Name] Not Like "~*") AND ([Name] Not Like
"MSys*"))
ORDER BY MsysObjects.Name;

You can turn it into an Append query (Append on Query menu from query
design) if you wish.

Add Type 6 if you want the linked tables as well, type 4 for ODBC linked
tables.

If you prefer to use code, try:
If (tdf.Attributes And dbSystemObject) = 0 Then

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Shadow said:
I'm trying to add the names of all tables in a database to a combobox.
But the names of system/hidden tables are added too.
this is what I did:

strFile = "C:\Program Files\Stock\OldData.mdb"
Set db = DBEngine.Workspaces(0).OpenDatabase(strFile)

For I = 0 To db.TableDefs.Count - 1
if not db.TableDefs(I).Attributes =dbHiddenObject then
cmbPastDataTables.AddItem db.TableDefs(I).Name
end if
Next I

How can I omit the system/hidden tables names to be added to the
combobox?
Any kind of help is much appreciated.
 

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