Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I am having unpredictable results with Hide, Show and Unload in 4 non-dependent userforms: frmInput, frmAllocate, frmReport, frmPrint. On each form are Hide and Quit (=unload) cmdbuttons. On a wsheet is a single 'Reveal' cmdbutton and cmdbuttons to invoke each form. In each Hide button the code is simply: Private Sub cmdHide_Click() frmReports.Hide 'frmReports for example End Sub The wsheet 'Reveal' button is: Sub RevealForm() If UserForms.Count 0 Then UserForms(0).Show 'Reveal hidden form Else MsgBox "No forms hidden." End If End Sub When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton which calls the forms is (frmInput by example): If UserForms.Count 0 Then If UserForms(0).Name = "frmInput" Then formname = "Input" If UserForms(0).Name = "frmAllocate" Then formname = "Allocate" If UserForms(0).Name = "frmReport" Then formname = "Report" If UserForms(0).Name = "frmPrint" Then formname = "Print" MsgBox "'Input Data' error" & vbCr & vbCr & _ "The " & formname & " form is still open. " Exit Sub 'This passes code to Show form being executed End If There is no point in leaving forms loaded as it can be a while before another utility is needed. Can anyone suggest where I might be going wrong or if there is a better strategy please? T.I.A Geoff |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am not getting what the problem is?
-- HTH Bob Phillips "Geoff" wrote in message ... Hi I am having unpredictable results with Hide, Show and Unload in 4 non-dependent userforms: frmInput, frmAllocate, frmReport, frmPrint. On each form are Hide and Quit (=unload) cmdbuttons. On a wsheet is a single 'Reveal' cmdbutton and cmdbuttons to invoke each form. In each Hide button the code is simply: Private Sub cmdHide_Click() frmReports.Hide 'frmReports for example End Sub The wsheet 'Reveal' button is: Sub RevealForm() If UserForms.Count 0 Then UserForms(0).Show 'Reveal hidden form Else MsgBox "No forms hidden." End If End Sub When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton which calls the forms is (frmInput by example): If UserForms.Count 0 Then If UserForms(0).Name = "frmInput" Then formname = "Input" If UserForms(0).Name = "frmAllocate" Then formname = "Allocate" If UserForms(0).Name = "frmReport" Then formname = "Report" If UserForms(0).Name = "frmPrint" Then formname = "Print" MsgBox "'Input Data' error" & vbCr & vbCr & _ "The " & formname & " form is still open. " Exit Sub 'This passes code to Show form being executed End If There is no point in leaving forms loaded as it can be a while before another utility is needed. Can anyone suggest where I might be going wrong or if there is a better strategy please? T.I.A Geoff |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton << What I am saying is that after a form has been unloaded I sometimes cannot call other forms because frmInput has been loaded during the unload process. 2 thoughts: 1. I believe that Userforms(0) refers to the currently loaded form, not an individual form? 2. frmInput uses a lot of variables, some of its functions are replicated - like date input txtboxes in the other forms. I have tried to be careful when unloading each form to set these global variables to nothing. But could that be what is causing a 'reference' to frmInput when unloading others? Geoff "Bob Phillips" wrote: I am not getting what the problem is? -- HTH Bob Phillips "Geoff" wrote in message ... Hi I am having unpredictable results with Hide, Show and Unload in 4 non-dependent userforms: frmInput, frmAllocate, frmReport, frmPrint. On each form are Hide and Quit (=unload) cmdbuttons. On a wsheet is a single 'Reveal' cmdbutton and cmdbuttons to invoke each form. In each Hide button the code is simply: Private Sub cmdHide_Click() frmReports.Hide 'frmReports for example End Sub The wsheet 'Reveal' button is: Sub RevealForm() If UserForms.Count 0 Then UserForms(0).Show 'Reveal hidden form Else MsgBox "No forms hidden." End If End Sub When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton which calls the forms is (frmInput by example): If UserForms.Count 0 Then If UserForms(0).Name = "frmInput" Then formname = "Input" If UserForms(0).Name = "frmAllocate" Then formname = "Allocate" If UserForms(0).Name = "frmReport" Then formname = "Report" If UserForms(0).Name = "frmPrint" Then formname = "Print" MsgBox "'Input Data' error" & vbCr & vbCr & _ "The " & formname & " form is still open. " Exit Sub 'This passes code to Show form being executed End If There is no point in leaving forms loaded as it can be a while before another utility is needed. Can anyone suggest where I might be going wrong or if there is a better strategy please? T.I.A Geoff |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you just trying to check whether a form is loaded or not?
If so, you need to loop through the userform collection For i = 0 To UserForms.Count - 1 'Find the one with the matching name If UserForms(i).Name = FormName Then MsgBox Formname & " loaded" Exit For End If Next i -- HTH Bob Phillips "Geoff" wrote in message ... Hi When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton << What I am saying is that after a form has been unloaded I sometimes cannot call other forms because frmInput has been loaded during the unload process. 2 thoughts: 1. I believe that Userforms(0) refers to the currently loaded form, not an individual form? 2. frmInput uses a lot of variables, some of its functions are replicated - like date input txtboxes in the other forms. I have tried to be careful when unloading each form to set these global variables to nothing. But could that be what is causing a 'reference' to frmInput when unloading others? Geoff "Bob Phillips" wrote: I am not getting what the problem is? -- HTH Bob Phillips |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I want to prevent frmInput being loaded during the unload process of other forms. Each wsheet cmdbutton checks to see if any form is hidden, if so, it gives a message and exits the sub. I think I am right in saying that if a form is 'referred' to it causes it to be loaded. In that line of logic then somehow a reference is being made to frmInput and it is that which causes it to be loaded? Can Userforms(0) be the cause or some of the global variables? I've done so much tesing on this I'm stuck and getting RSS. Geoff "Bob Phillips" wrote: Are you just trying to check whether a form is loaded or not? If so, you need to loop through the userform collection For i = 0 To UserForms.Count - 1 'Find the one with the matching name If UserForms(i).Name = FormName Then MsgBox Formname & " loaded" Exit For End If Next i -- HTH Bob Phillips "Geoff" wrote in message ... Hi When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton << What I am saying is that after a form has been unloaded I sometimes cannot call other forms because frmInput has been loaded during the unload process. 2 thoughts: 1. I believe that Userforms(0) refers to the currently loaded form, not an individual form? 2. frmInput uses a lot of variables, some of its functions are replicated - like date input txtboxes in the other forms. I have tried to be careful when unloading each form to set these global variables to nothing. But could that be what is causing a 'reference' to frmInput when unloading others? Geoff "Bob Phillips" wrote: I am not getting what the problem is? -- HTH Bob Phillips |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Geoff,
I am trying, believe me, but struggling somewhat. You don't actually refer to a form, just check the userforms collection, so that shouldn't load a form. Can you post all of the code and describe a series of actions that will demonstrate the problem, you know, like click button A, form a shows, click hide on that form, etc. as I cannot fully visualise the whole picture. -- HTH Bob Phillips "Geoff" wrote in message ... Hi I want to prevent frmInput being loaded during the unload process of other forms. Each wsheet cmdbutton checks to see if any form is hidden, if so, it gives a message and exits the sub. I think I am right in saying that if a form is 'referred' to it causes it to be loaded. In that line of logic then somehow a reference is being made to frmInput and it is that which causes it to be loaded? Can Userforms(0) be the cause or some of the global variables? I've done so much tesing on this I'm stuck and getting RSS. Geoff "Bob Phillips" wrote: Are you just trying to check whether a form is loaded or not? If so, you need to loop through the userform collection For i = 0 To UserForms.Count - 1 'Find the one with the matching name If UserForms(i).Name = FormName Then MsgBox Formname & " loaded" Exit For End If Next i -- HTH Bob Phillips "Geoff" wrote in message ... Hi When unloading say frmReport, frmInput is often loaded but not shown. This means none of the forms can be shown as in each of the wsheet cmdbutton << What I am saying is that after a form has been unloaded I sometimes cannot call other forms because frmInput has been loaded during the unload process. 2 thoughts: 1. I believe that Userforms(0) refers to the currently loaded form, not an individual form? 2. frmInput uses a lot of variables, some of its functions are replicated - like date input txtboxes in the other forms. I have tried to be careful when unloading each form to set these global variables to nothing. But could that be what is causing a 'reference' to frmInput when unloading others? Geoff "Bob Phillips" wrote: I am not getting what the problem is? -- HTH Bob Phillips |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Making the forms scroll bar show - figures. | Excel Worksheet Functions | |||
How can I hide check box created via FORMS together with column? | Excel Discussion (Misc queries) | |||
How do I hide the outline of a Forms Group Box? | Excel Discussion (Misc queries) | |||
Can you hide forms checkboxes | Excel Programming | |||
how do you hide a forms command button | Excel Programming |