Child Form Can't Update Parent... 
Author Message
 Child Form Can't Update Parent...

I've got a child form that is trying to update a progress bar and a label
caption on a parent and I keep getting the error message,
"Only one MDI form allowed".

There must be some simple way to update a value on a parent. At this point the
only think I can think of is passing the value to the parent by updating a
global variable and then using a timer in the parent to check the global
variable. There's got to be an easier way.

Any ideas? Thanks for your help on this.

Paul
Seattle, WA



Thu, 13 Nov 2003 04:55:51 GMT  
 Child Form Can't Update Parent...
Are you setting up an object variable to point to the MDI main form? That
doesn't work well.. Just hard code the name of the form and it should work.

'===========Child Form code
'Works like a charm
Private Sub Form_Click()
   MDIForm1.Caption = "This is a Test: " & Timer
End Sub
'===========


Quote:
> I've got a child form that is trying to update a progress bar and a label
> caption on a parent and I keep getting the error message,
> "Only one MDI form allowed".

> There must be some simple way to update a value on a parent. At this point
the
> only think I can think of is passing the value to the parent by updating a
> global variable and then using a timer in the parent to check the global
> variable. There's got to be an easier way.

> Any ideas? Thanks for your help on this.

> Paul
> Seattle, WA



Thu, 13 Nov 2003 05:01:26 GMT  
 Child Form Can't Update Parent...

Quote:
>Are you setting up an object variable to point to the MDI main form? That
>doesn't work well.. Just hard code the name of the form and it should work.
>'===========Child Form code
>Private Sub Form_Click()
>   MDIForm1.Caption = "This is a Test: " & Timer
>End Sub

More like: "MDIForm.ProgressBar.Value = 1"
And that's what's generating the error message. There must be some reason why
a child is not supposed to update a parent MDI form. In your example, you
updating the the title bar caption. I tried it and  but I got the same error.
Quote:
>> "Only one MDI form allowed".
>> There must be some simple way to update a value on a parent.



Thu, 13 Nov 2003 06:50:27 GMT  
 Child Form Can't Update Parent...

Quote:
> >Are you setting up an object variable to point to the MDI main form? That
> >doesn't work well.. Just hard code the name of the form and it should
work.
> >'===========Child Form code
> >Private Sub Form_Click()
> >   MDIForm1.Caption = "This is a Test: " & Timer
> >End Sub

> More like: "MDIForm.ProgressBar.Value = 1"
> And that's what's generating the error message. There must be some reason
why
> a child is not supposed to update a parent MDI form. In your example, you
> updating the the title bar caption. I tried it and  but I got the same
error.

Check how the MDI form is being loaded.  I'll bet it's something like:
dim f as mdiform1
set f=new mdiform1
f.show

If so, you have created an instance of the mdi parent and then probably let
the reference go out of scope.  When you try to use the implicit "MDIForm1"
global variable you are asking for a second instance to be created.

You can change the creation code to just use MDIForm1.Show or you can add
"Set MDIForm1=f" to the existing code or you can locate the form in the
Forms collection and use Forms(x).ProgressBar.Value=1



Thu, 13 Nov 2003 06:57:25 GMT  
 Child Form Can't Update Parent...

Quote:
>Check how the MDI form is being loaded.  I'll bet it's something like:
>dim f as mdiform1
>set f=new mdiform1
>f.show

>If so, you have created an instance of the mdi parent and then probably let
>the reference go out of scope.  When you try to use the implicit "MDIForm1"
>global variable you are asking for a second instance to be created.

You won that bet! That was exactly it. Many thanks.

I'll follow up, by answering some of the more simple questions in this forum
myself. You helped me. I help someone else.

Thanks Bob!

Paul,
in Seattle, WA



Fri, 14 Nov 2003 02:18:36 GMT  
 Child Form Can't Update Parent...

Azrial plunged through his body were:

Quote:
>Since a picture's worth a thousand words, see for yourself... Attached
>"mini" project shows the method I used..

uhhh, many people don't like people posting files in nonbinaries
groups due to the fact that ISPs have cancelled groups because of this
happening.
Hellmark
-If you can't dazzle them with brilliance, then baffle them with bullshit!


Sat, 22 Nov 2003 12:41:15 GMT  
 Child Form Can't Update Parent...
If you created your app with VB's Wizard then you can access the MDI Form by
using

fMainForm.StatusBar1.Value = 100

In the Sub_Main code you should see a line like :

Dim fMainForm As New frmMain

Let me know if this works.
-Rick

_________________________________________________
For More VB Examples visit http://www.visualbasic101.com/


Quote:
> I've got a child form that is trying to update a progress bar and a label
> caption on a parent and I keep getting the error message,
> "Only one MDI form allowed".

> There must be some simple way to update a value on a parent. At this point
the
> only think I can think of is passing the value to the parent by updating a
> global variable and then using a timer in the parent to check the global
> variable. There's got to be an easier way.

> Any ideas? Thanks for your help on this.

> Paul
> Seattle, WA



Sun, 23 Nov 2003 09:18:09 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. MDI child form is moving down from it's parent

2. VB5: Crystal Reports child-window haven't title in MDI-parent form

3. Help: Change a MDI child's parent MDI form at run-time

4. MSHFlexGrid format child side in parent child form

5. requery parent form when user adds a record to child form

6. how child form find out parent form?

7. Modifying object in MDI Parent form from MDI Child form

8. Loading MDI Child forms to a parent form from a DLL

9. Centreing a child form in a parent form

10. Making a child form much bigger than the parent MDI form

11. Show a form - not as child - outside a MDI-parent form

12. Parent Form and Child Form...editable

 

 
Powered by phpBB® Forum Software