?
Solved

same form loading twice

Posted on 2006-06-29
6
Medium Priority
?
451 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 1400 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 200 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 200 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
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 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 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

Technology Partners: 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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
Course of the Month11 days, 15 hours left to enroll

752 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