View Full Version : Getting a list of forms, tables, and queries into a combo box


cawillwe
05-23-2001, 04:18 AM
I'm trying to get 2 combo boxes to populate:
1. Has a list of all tables and queries in the database
2. Has a list of all forms

The first one is working, but may be a little sloppy:
Me.TableName.RowSource = ""
For Each tabledef In CurrentDb().TableDefs
If Left(tabledef.Name, 4) <> "MSys" Then
Me.TableName.RowSource = Me.TableName.RowSource & tabledef.Name & ";"
End If
Next
For Each querydef In CurrentDb().queryDefs
If Left(querydef.Name, 4) <> "~sq_" Then
Me.TableName.RowSource = Me.TableName.RowSource & querydef.Name & ";"
End If
Next

The second is not working, and the code I have now is below:
Do While i < Application.Forms.Count
If Left(Application.Forms(i).Name, 9) <> "frmSearch" Then
Me.FormToOpen.RowSource = Me.FormToOpen.RowSource & Application.Forms(i).Name & ";"
End If
i = i + 1
Loop

Any help, especially on the 2nd box, would be greatly appreciated. Thanks

cawillwe
05-23-2001, 04:19 AM
I should mention that the reason it checks for Left(Forms(i).Name,9) is to exclude the forms "frmSearch" and "frmSearches," which I have created in the database.

cawillwe
05-23-2001, 04:24 AM
Naturally, 2 minutes after I posted this I found a good reference msdn.com: http://msdn.microsoft.com/library/periodic/period01/ino2k.htm

Sorry if anyone already started this.