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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Forms/Reports in a listbox 1

Status
Not open for further replies.

Drummermoose

Technical User
Jan 22, 2002
48
GB
I want to create a main menu for my database with a listbox which displays forms and reports I have in my database. I also want it to list each form twice 1)add new 2)edit.

If it is possible I want to type description names which will be displayed in the listbox instead of the table/report name.

Any help appreciated.

Thanks.
 
Moose:

This should get you started. Create a listbox called lstForms. Set its "row source type" to "value list". Set its "column count" to 2. Add a command button to the form and place this code in its "Click" event.

Dim dbs As Database
Dim ctr As Container
Dim doc As Document
Dim sRowSource As String
Dim i As Integer

' Return reference to current database.
Set dbs = CurrentDb

' Return referenct to Forms container.
Set ctr = dbs.Containers!Forms

' Enumerate through Documents collection of Forms container.
i = 1
For Each doc In ctr.Documents
' Build rowsource for listbox.

If i = 1 Then

sRowSource = doc.Name & ",Edit;"

Else

sRowSource = sRowSource & ";" & doc.Name & ",Edit;"

End If

sRowSource = sRowSource & doc.Name & ",Add New"

i = i + 1

Next doc
Set dbs = Nothing

Me.lstForms.RowSource = sRowSource


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top