Announcement

Collapse
No announcement yet.

Unload a UserForm?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unload a UserForm?

    Thanks for everyones help so far..

    Question: I have Userforms that are displayed by Command Buttons when clicked hides one and shows another
    Code:
    Private Sub CommandButton2_Click()
     UserForm6.Hide
     UserForm8.Show
    End Sub
    Problem is, else where in the program I have a Maintenance Menu that sets a "maintenance value" to off or on, I have the following code used in the UserForm_Initialize that fires the first time a UserForm loads, but doesnt fire again if the page is re-displayed.
    Code:
    Private Sub UserForm_Initialize()
    ' Added Maintence Option for use in TroubleShooting - 3/2/02
    MaintOption = Worksheets("Data").Cells(1, 13).Value
    If MaintOption = "On" Then
     CommandButton4.Caption = "Test Info"
    ElseIf MaintOption = "Off" Then
     CommandButton4.Caption = ""
     CommandButton4.Enabled = False
      End If
    End Sub
    If I change the Maintenance Option from Off to On, and I have already been on that page, I need the Button to be displayed and same goes if I have already been to the page, see I forgot to turn on the maintenace option, go back turn it on, It won't display the button still, the UserForm_Initialize doesn't fire again..

    Any ideas on what to change ?
    Thanks!
    Joe
    Last edited by Jack in the UK; December 3rd, 2004, 07:51. Reason: Code Tags Added - jiuk

  • #2
    Re: Unload a UserForm?

    Hi Joe

    Just a quick one can you please use Code Tags [i have added them for you] when you post VBA just the way we like the codes postsed on OzGrid and you have to admind they look clear and super cool, not to add makes my adminstration easier, not digging buddy - but also helps for other members reading this post in the future.

    Many thank for your understanding

    Jack

    Comment


    • #3
      Re: Unload a UserForm?

      Hey no problem, I was wondering how that was done.
      I thought that was kewl looking too. Thanks for the heads up. I will use them from now on.

      Comment


      • #4
        Re: Unload a UserForm?

        Hey all... still looking for a fix, and nothing is working right..

        I read up on Load and Unloading UserForms, but for some reason, it will not work.

        I have tried

        Code:
        UserForm6.Hide
         Unload UserForm6
          Load UserForm8
         UserForm8.Show
        I have tried the:

        Code:
        Unload Me
           UserForm8.Show
        All to no avail, when I leave and go back to the form, its still populated and the UserForm Initialize does not fire again. Maybe it will only fire once per open workbook session, if thats the case, any ideas on how to do this? Clearing the form isn't an issue, its just when the form loads, it needs to look for a value and react accordingly.. so I need something that will check for that value every time..

        Ideas ? Thanks.

        Joe

        Comment


        • #5
          Re: Unload a UserForm?

          Hi Joe,

          Try moving the code into the Activate event.

          Code:
          Private Sub UserForm_Activate()
          
          End Sub

          Cheers
          Andy

          Comment


          • #6
            Re: Unload a UserForm?

            Andy,

            You ROCK! I didn't know about that event... that will help ALL over my project. THANK YOU!



            Joe

            Comment

            Working...
            X