Solved

same form loading twice

Posted on 2006-06-29
6
439 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 142

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now