List Box of Form Names

  • Thread starter Thread starter Katrina
  • Start date Start date
K

Katrina

I would like to create a list box filled with the form
names. I would like to write a code that will search
through the forms' names and then list them in the list
box so that they can be selected.

Does anyone know what code I could use for this?

Katrina
 
Assuming you have a listbox called: lstForms

Dim o As Object
Dim sSource As String

For Each o In CurrentProject.AllForms
sSource = sSource & o.Name & ";"
Next

sSource = Mid$(sSource, 1, Len(sSource) - 1)
With Me.lstForms
.RowSourceType = "Value List"
.RowSource = sSource
End With

Krgrds,
Perry
 
Try something along the following lines

Dim frm As AccessObject
Dim strRowSource As String

For Each frm In CurrentProject.AllForms
strRowSource = strRowSource & frm.Name & ";"
Next
strRowSource = Left(strRowSource, Len(strRowSource) - 1)
List0.RowSource = strRowSource

List0 is the name of the list box.

Hope This Helps
Gerald Stanley MCSD
 
Both those methods will work, but I prefer:

Set the Listbox's RecordSource to:

Select Name from MSYSObjects where Type = -32768


Chris
 
Back
Top