G
Guest
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
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