Solved

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

Posted on 2002-05-01
5
119 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now