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
Solved

Using a common MDI form both for standard call and for modal call

Posted on 2002-05-01
5
122 Views
Last Modified: 2010-05-02
Let's say I have form A, that is an MDI form. Let's say it's used to handle customers.
Now I want to have my main menu able to call that A form, and keep it open while I open my... let's say Invoice form where I want to show form A, but in vbModal way (of course if you have formA.mdichild = true then you can't show it vbModal).
The problem is that if I copy the form with a:

Dim B as new FormA

I can't modify the MDIChild property, as it is read-only in run-time.
So, is there a way, different from saving the file and changing the form name to show it both as MDI and as Modal?

Thank you
0
Comment
Question by:DataSol
5 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 6984850
The only way I can think of is to dynamically copy the contents of the child form into a standard form which can then be show modally.  The copy would require moving each object to the proper location and making it visible.  This part is easy, but may be a bit slow if you have a lot of controls and have to unload it each time (rather than load it just the first time then leave it hidden.)
0
 

Author Comment

by:DataSol
ID: 6984862
Rspahitz: ok, I can dynamically create the objects on the new form, but what about the code related to events?
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 50 total points
ID: 6984883
Each event would probably have to be predefined (which they are in the child form anyway) and then called.  In that case, maybe the easiest thing to do would be to have every event procedure call a procedure in a new module, like this:
-----
FormA:
-----
Private Sub Command1_Click(Index as Integer)
   MyModule.Command1_Click Me.Name, Index
End Sub

Private Sub Form_Load()
   MyModule.Form_Load Me.Name
End Sub

-----
FormB:
-----
Private Sub Command1_Click(Index as Integer)
   MyModule.Command1_Click Me.Name, Index
End Sub

Private Sub Form_Load()
   MyModule.Form_Load Me.Name
End Sub

-----
MyModule:
-----
Public Sub Command1_Click(FormName as string, Index as Integer)
   if Index = 0 then
     'so something for first index
   else
     ' do something for next index
   endif
End Sub

Public Sub Form_Load(FormName as String)
   if Formname = "FormA" then
     'do something special for form A
   else
     'do something special for form B
   endif
End Sub

---
The references to Formname are optional, but may be useful.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7698702
Hi DataSol,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rspahitz's comment(s) as an answer.

DataSol, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7755549
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
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

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 (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

829 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