Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

loading new copies of a form

Posted on 2004-10-03
12
Medium Priority
?
189 Views
Last Modified: 2010-05-02
I have a program which has a menu system similar to the start menu used by windows. but because my forms dont have boarders i cant use the menu editor. So therefore i have made a system using forms. but the problem is I cant load another instance of the same form without the other one disappearing. I know u can use MDI forms but i cant take the boarder off the MDI form. Any ideas?
0
Comment
Question by:schoi_ukuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
12 Comments
 
LVL 19

Expert Comment

by:Shauli
ID: 12211544
Dim newForm As Form1    'modify to your form name
Set newForm = New Form1   'modify to your form name
newForm.Show


S
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12211894
As an alternative, you could make a standard form with your menu structure.  This form would be loaded, but hidden.  This way you could access the menu using PopupMenu.

ex:

PopupMenu frmHidden.mnuPop1
0
 
LVL 2

Accepted Solution

by:
x_terminat_or_3 earned 100 total points
ID: 12212227
The technique described by Shauli is a good way to load multiple instances of the same form.

You should, however, keep track of all instances, and close all of them when closing the program.

This can be done easily with the Collection class

Here's an example.  Change Form1 to the name of the form to be created


Option Explicit
Dim cForms As Collection

Private Sub Command1_Click()
    Dim cForm As Form1
   
    Set cForm = New Form1
   
    cForms.Add cForm
   
    cForm.Show
   
End Sub

Private Sub Form_Load()
    Set cForms = New Collection
   
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'unload all forms
    Dim cForm As Form1, lngCount As Long
   
    For lngCount = 1 To cForms.Count
        Set cForm = cForms.Item(lngCount)
       
        Unload cForm
    Next lngCount
End Sub



With kind regards


Ramses (x_terminat_or_3)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 100 total points
ID: 12212266
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    'unload all forms
    Dim cForm As Form1
   
    For Each cForm In Forms
        If Not cForm.Name = Me.Name Then
               cForm.Hide
              Unload cForm
              Set cForm = Nothing
         End If
    Next
End Sub

This is the correct way to unload all open forms.

S

0
 
LVL 19

Expert Comment

by:Shauli
ID: 12212271
One correction:

Dim cForm As Form
'                     ^^^^

S
0
 
LVL 2

Expert Comment

by:x_terminat_or_3
ID: 12212275
both methods are good, although yours is easier...
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12212316
If you are loading new instances of the main form, then:

If Not cForm.Name = Me.Name Then '<< Will not work because all the names are the same.

I think you mean to use:

If Not cForm Is Me Then
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12212328
Erick37 , Absolutely right.  :)

S
0
 
LVL 2

Expert Comment

by:x_terminat_or_3
ID: 12559516
Split Shuili x_terminat_or_3
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question