Solved

same form loading twice

Posted on 2006-06-29
6
443 Views
Last Modified: 2008-10-06
am using VB6.

I have a MDI parent )mdiMain) and two MDI Child forms. ( FOrm1 and Form2)

When the application opens the Form 1 (transacation entry) opens in the MDI parent screen.

I click on the menu to open Form 2 ( form 1 is still open). Form2 is History form displaying transactions entered. From Form 2 I wish to open the same Form1 for editing the transactions. But instead it is creating a new instance of Form1. So there are two versions of the FORM 1

How do I set focus on the form 1 that is already open and visible ? I do not want FORM 1 to be created again.

I will appreciate any help in this regard.
0
Comment
Question by:subodh2005
6 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 350 total points
ID: 17015459
What you need to do is keep track of what forms are open; you can do this on load - by having the parent control - and when form 2 wants to load a form - it asks the parent to load it; in doing so the parent checks if an instance of form 1 is already open - and returns that - rather than a new instance of the form.
0
 
LVL 15

Assisted Solution

by:JackOfPH
JackOfPH earned 50 total points
ID: 17015486
you can clone a form1. here is how

Dim frmDuplicate As New form1  ` ***** change to the name of the form you want to duplicate *****
frmDuplicate.Show

frmDuplicate.caption = "I am duplicate of Form1 hehehe!"
0
 
LVL 9

Assisted Solution

by:pradapkumar
pradapkumar earned 50 total points
ID: 17015748
do not mdi forms to handle this like scenario. at the beggining of my projects development I have also faced this like problems. To overcome this i used standard forms and i used vbModal forms. They won't allow you to make multiple instances of your forms.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 50 total points
ID: 17016455
adding to the above comments:

you should NOT have the mdi child form as startup form, but the main MDI form.
in the MDI main form Load() event, start the child form by code, by keeping it's reference in the standard module

--- module code ----

Public gfrmMDIChild1 as Form1

---------------------

MDI Startup form code:


 set gfrmMDIChild1 = new Form1
 gfrmMDIChild1.Show


On Form2, trying to set the focus to form1 again:

  gfrmMDIChild1.SetFocus


0
 

Author Comment

by:subodh2005
ID: 17018831
Thanks everyone for quickly responding to my proble. I will go with Raynard's solution. I have split the points because I think you need to get points for the time you spent.

Thanks
0
 
LVL 9

Expert Comment

by:pradapkumar
ID: 17024107
Nice thaught dear subodh2005.
I appreciate this like attitude and i wish u all the success in your life.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

828 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