Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Show and Hide Forms

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Show and Hide Forms

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Show and Hide Forms

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Show and Hide Forms

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Show and Hide Forms

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Show and Hide Forms

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making the forms scroll bar show - figures. Martc Excel Worksheet Functions 2 May 2nd 07 11:12 AM
How can I hide check box created via FORMS together with column? Max Excel Discussion (Misc queries) 3 March 25th 05 08:49 PM
How do I hide the outline of a Forms Group Box? MadTodd Excel Discussion (Misc queries) 7 January 17th 05 05:45 PM
Can you hide forms checkboxes Matt Excel Programming 2 January 10th 04 06:32 PM
how do you hide a forms command button Paul James[_3_] Excel Programming 4 September 5th 03 06:18 PM


All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"