Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

same form loading twice

Posted on 2006-06-29
6
Medium Priority
?
457 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
Industry Leaders: 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!

 
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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 …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

636 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