How It Works

First, you created a new form and added a list box object and a command button object to the form. You then set several properties of the list box and command button objects using the Properties dialog box. Next, you created an event procedure to run whenever the user clicks the cmdGetForms command button. The event procedure looped through the Forms collection to obtain a list of each open form in the application and added the names of any open form to the list box.

Private Sub cmdGetForms_Click()

Dim frmForms As Form

'loop through forms collection and 'add name of each open form to list box For Each frmForms In Forms

Me.lstForms.AddItem (frmForms.Name) Next frmForms

End Sub

More forms are included in the database than the one displayed. Is this an error? No, it is not. The reason you see the name of only one form in the list box is because it is the only form that is open. You can use the other collections and objects , whether or not they are open, as you will see in a later example.

0 0

Post a comment