#1   Report Post  
LB79
 
Posts: n/a
Default Form not hiding


Hello - Hope someone can help - this is driving me mad.
Ive looked at the other threads relating to this but the advice hasnt
seemed to work for me.
I have a userform that has a button. When the button is pushed the
first userform should close and and a second should open. This works
except the first userform stays visible in the background.
Ive tried using DoEvents and unloading but this hasnt worked for me.
Ive tried the following codes:

Sub B()
form2.Show
form1.Hide
DoEvents
End Sub

Sub A()
form1.Hide
form2.Show
DoEvents
End Sub

Thanks


--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Shouldn't B be:

Sub B()
form1.Hide
form2.Show
DoEvents
End Sub

Try changing the doEvents to:
msgbox "hi"

And you'll see when it gets executed (in the original sub).


LB79 wrote:

Hello - Hope someone can help - this is driving me mad.
Ive looked at the other threads relating to this but the advice hasnt
seemed to work for me.
I have a userform that has a button. When the button is pushed the
first userform should close and and a second should open. This works
except the first userform stays visible in the background.
Ive tried using DoEvents and unloading but this hasnt worked for me.
Ive tried the following codes:

Sub B()
form2.Show
form1.Hide
DoEvents
End Sub

Sub A()
form1.Hide
form2.Show
DoEvents
End Sub

Thanks

--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483


--

Dave Peterson
  #3   Report Post  
LB79
 
Posts: n/a
Default


Thanks for that.
I changed the DoEvents to MSGBOX "hi" and it didnt pop up until i
closed the second form, which indicates that DoEvents is being
ignored?
How can i force DoEvents to work where i want it to?


--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't think it's being ignored. I think your code is waiting for the other
userform to finish what it has to do.

So you'll either have to rearrange the order of what you do (my first
suggestion) or if you're running xl2k+, you can load the second form like:

Sub B()
form2.Show false
form1.Hide
DoEvents
End Sub

The false means that you're loading the form is modeless. The user can click on
cells and continue to work. (It may not be what you want to allow.)

(why not just change the order of the .hide and .show?)

LB79 wrote:

Thanks for that.
I changed the DoEvents to MSGBOX "hi" and it didnt pop up until i
closed the second form, which indicates that DoEvents is being
ignored?
How can i force DoEvents to work where i want it to?

--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483


--

Dave Peterson
  #5   Report Post  
LB79
 
Posts: n/a
Default


Im still not getting this. My code is:

Private Sub CommandButton1_Click()
Menu1.Hide
Menu2.Show
DoEvents
End Sub

but the Menu1 is still showing in the background. Ive tried adding in
more then 1 DoEvents too but i cant seem to get it.


--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

Your code worked fine for me (as-is).

Did you try the doEvents this way?
Option Explicit
Private Sub CommandButton1_Click()
menu1.Hide
DoEvents
menu2.Show
DoEvents
End Sub

Is this all your code (or just a snippet)?

If you have "application.screenupdating = false", then turn it back on after you
hide the form:

Option Explicit
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
'more code here
menu1.Hide
Application.ScreenUpdating = True
'application.screenupdating = false 'if you want
menu2.Show
DoEvents
End Sub


LB79 wrote:

Im still not getting this. My code is:

Private Sub CommandButton1_Click()
Menu1.Hide
Menu2.Show
DoEvents
End Sub

but the Menu1 is still showing in the background. Ive tried adding in
more then 1 DoEvents too but i cant seem to get it.

--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483


--

Dave Peterson
  #7   Report Post  
LB79
 
Posts: n/a
Default


It works for me now too (as-is). I didnt think to enable
screenupdating.

Thank you


--
LB79
------------------------------------------------------------------------
LB79's Profile: http://www.excelforum.com/member.php...o&userid=12156
View this thread: http://www.excelforum.com/showthread...hreadid=396483

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
Display form from an VB application in Excel kuhni Excel Discussion (Misc queries) 0 August 10th 05 06:04 PM
Worksheet form design rgarber50 Excel Discussion (Misc queries) 4 August 7th 05 05:09 AM
Print scrollable user form. cparsons Excel Discussion (Misc queries) 2 August 4th 05 04:45 PM
Is there a way to convert a EXCEL form into a WORD form? Carole O Excel Discussion (Misc queries) 1 April 27th 05 10:13 PM
Trying to delete form border, and it deletes all borders PeterM Excel Discussion (Misc queries) 11 January 3rd 05 03:36 PM


All times are GMT +1. The time now is 08:53 PM.

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

About Us

"It's about Microsoft Excel"