Solved

same form loading twice

Posted on 2006-06-29
6
448 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
[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
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

717 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