How can I populate a list box with all form names

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

Guest

Is there a way to populate a list box with the names of all the forms in a
database? I have done this for the tables, but can't seem to find a way to
do this for the forms. Here is the code I used for the tables.

Me.lstTables.RowSourceType = "Value List"
Me.lstTables.RowSource = ""

For i = 0 To CurrentDb.TableDefs.Count - 1
strAddList = CurrentDb.TableDefs(i).Name

If Left(strAddList, 4) <> "mSys" Then
Me.lstTables.AddItem strAddList
End If

Next

Me.lstTables.AddItem "All"

Is there something similar for forms? I am using Access 2002.
 
Set the RowSource of the list box to something like this:

SELECT MSysObjects.Name
FROM MSysObjects
WHERE ((MSysObjects.Name Not Like "~*")
AND (MSysObjects.Type = -32768))
ORDER BY MSysObjects.Name;
 
Is there a way to populate a list box with the names of all the forms in a
database? I have done this for the tables, but can't seem to find a way to
do this for the forms. Here is the code I used for the tables.

Me.lstTables.RowSourceType = "Value List"
Me.lstTables.RowSource = ""

For i = 0 To CurrentDb.TableDefs.Count - 1
strAddList = CurrentDb.TableDefs(i).Name

If Left(strAddList, 4) <> "mSys" Then
Me.lstTables.AddItem strAddList
End If

Next

Me.lstTables.AddItem "All"

Is there something similar for forms? I am using Access 2002.

Here is how you can see all Tables, Queries, Forms, and Reports.

Set the list box RowsourceType to table/query

For Forms, set the Rowsource to:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((MSysObjects.Type)=-32768)) ORDER BY MSysObjects.Name;

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

For Queries:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)) ORDER BY
MSysObjects.Name;

For Reports:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=-32764)) ORDER BY
MSysObjects.Name;
 
fredg said:
Is there a way to populate a list box with the names of all the forms in a
database? I have done this for the tables, but can't seem to find a way to
do this for the forms. Here is the code I used for the tables.

Me.lstTables.RowSourceType = "Value List"
Me.lstTables.RowSource = ""

For i = 0 To CurrentDb.TableDefs.Count - 1
strAddList = CurrentDb.TableDefs(i).Name

If Left(strAddList, 4) <> "mSys" Then
Me.lstTables.AddItem strAddList
End If

Next

Me.lstTables.AddItem "All"

Is there something similar for forms? I am using Access 2002.

Here is how you can see all Tables, Queries, Forms, and Reports.

Set the list box RowsourceType to table/query

For Forms, set the Rowsource to:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((MSysObjects.Type)=-32768)) ORDER BY MSysObjects.Name;

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

For Queries:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=5)) ORDER BY
MSysObjects.Name;

For Reports:
SELECT MSysObjects.Name FROM MSysObjects WHERE
(((Left([Name],1))<>"~") AND ((MSysObjects.Type)=-32764)) ORDER BY
MSysObjects.Name;

Thank you to both of you for replying.

Nathan
 
Back
Top