Author |
Message |
Paul Townse #1 / 7
|
 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 |
|
 |
Ken Halte #2 / 7
|
 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 |
|
 |
Paul Townse #3 / 7
|
 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 |
|
 |
Bob Butle #4 / 7
|
 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 |
|
 |
Paul Townse #5 / 7
|
 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 |
|
 |
Hellmar #6 / 7
|
 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 |
|
 |
Rick #7 / 7
|
 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 |
|
|