+ Reply to Thread
Results 1 to 11 of 11

Opening a userform while another is open

Hybrid View

  1. #1
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    87

    Opening a userform while another is open

    Hello all!
    Not sure if the title really says what I want.

    Anyways, I have a userform that allows me to edit an order. When I edit the order and click "done" (commandbutton) the code changes the order by moving what I typed in the textbox to a cell on a worksheet.

    With this userform (and some others in my workbook) I would like to open another userform that has an animated gif in a webbrowser stating that excel is processing, while the first userform is running its code. When the code is finished, I want the second userform (processing) to go away.

    I have already tried opening as "vbmodeless", but it says that I cant do that!

    Any suggestions?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Opening a userform while another is open

    Hello rbyrd023,

    While the first UserForm is running, hide it and then show the second form. Once the first form is done then close the second form and show the first.

    In UserForm1
      Me.Hide
      UserForm2.Show
    
      'Code to do processing
    
      'Close UserForm2
       SendKeys "%{F4}"
    
      Me.Show
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Opening a userform while another is open

    Thank you for the response. I just tried that, but the first userform will not execute the code while the second form is running.

    Here is the code I have on that command button:
    Private Sub CommandButton1_Click()
    Me.Hide
    
    frmTest.Show
    
    
    Sheets("Material Worksheet").Range("A118").Value = TextBox1.Value
    Sheets("Material Worksheet").Range("B118").Value = TextBox2.Value
    Sheets("Material Worksheet").Range("C118").Value = TextBox3.Value
    
    Label1.Caption = TextBox1.Value
    Label2.Caption = TextBox2.Value
    Label3.Caption = TextBox3.Value
    CommandButton1.Visible = False
    TextBox1.Visible = False
    TextBox2.Visible = False
    TextBox3.Visible = False
    Label1.Visible = True
    Label2.Visible = True
    Label3.Visible = True
    Edit1.Visible = True
    del1.Visible = True
    Unload frmTest
    SendKeys "%{F4}"
    Me.Show
    
    
    
    End Sub

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Opening a userform while another is open

    Hello rbyrd023,

    You have unloaded the form and then tried to close it. Because the second for is already closed, the SendKeys will close whichever window has the focus. I removed the SendKeys from the code.
    Private Sub CommandButton1_Click()
    
    Me.Hide
    
    frmTest.Show
    
    
    Sheets("Material Worksheet").Range("A118").Value = TextBox1.Value
    Sheets("Material Worksheet").Range("B118").Value = TextBox2.Value
    Sheets("Material Worksheet").Range("C118").Value = TextBox3.Value
    
    Label1.Caption = TextBox1.Value
    Label2.Caption = TextBox2.Value
    Label3.Caption = TextBox3.Value
    CommandButton1.Visible = False
    TextBox1.Visible = False
    TextBox2.Visible = False
    TextBox3.Visible = False
    Label1.Visible = True
    Label2.Visible = True
    Label3.Visible = True
    Edit1.Visible = True
    del1.Visible = True
    
    Unload frmTest
    
    Me.Show
    
    End Sub

  5. #5
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: Opening a userform while another is open

    Ok tried that and still have the same result.

    while frmtest is open, the remaining code will not run. I have to close frmtest manually for the rest of the code to start.

    This is really bothering me....... lol I know it can be done!

    Thank you again for your help!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Opening a userform while another is open

    Hello rbyrd023,

    You should post your workbook for review.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Opening a userform while another is open

    From what you describe I really can't see why your code should take enough time to need the warning form
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Opening a userform while another is open

    I'm not sure if this is correct, but when you start the second form it's code starts to run, that will stop the original code until completed. As I said earlier, I can't see why you should need a progress form for simply writing data to the sheet. I think your time would be better used to improve the efficiency of the code by finding out why it takes so long to run

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1