Results 1 to 5 of 5

Thread: Contain information in userform
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jan 2011
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Contain information in userform

    Hi,
    Is it possible to save the data that has been entered in a textbox within a userform so the information still will be in there after you close it? I'm using the .Hide command, but mabye there is a code that just sends the userform to the back without closing it?

    If not, is it possible to add an excelsheet in a userform? Will this save the data?

    Other suggestions how to save the data without unloading the form is of course welcome.
    Thanks

  2. #2
    New Member
    Join Date
    Jan 2011
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Contain information in userform

    Other suggestions how to save the data without unloading the form is of course welcome.

  3. #3
    Board Regular Weaver's Avatar
    Join Date
    Sep 2008
    Posts
    5,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Contain information in userform

    You could change the .top property of the form so it's a higher value than your visible screen height. It won't be visible but it will still be active. Of course, this will only work if the .showmodal is false.

    Also, are you using .activate or .initialize event to set up your form in the first place? I think that if you do it all using .initialize, then .hide & .show won't reset the values, as these events don't trigger the .activate code.
    If the above suggestion contains vb code and you're not sure about using macros,check the following links (which in no way should be interpreted as being specific to your individual query):

    http://www.mrexcel.com/articles/past...o-into-vbe.php

    You can find help with array formulas here:

    http://www.cpearson.com/excel/arrayformulas.aspx

    If you really want to learn Excel, don't always accept the first solution.

  4. #4
    New Member
    Join Date
    Jan 2011
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Contain information in userform

    Thanks for your input, Weaver

    You could change the .top property of the form so it's a higher value than your visible screen height. - I tried that, however it only sent the userform to the far edge of the screen, covering my workbook. I did not use .showmodal as i'm not familiar with this function. Like this?

    Private sub workbook_activate()
    Application.showmodal = False
    End sub

    If i change the .top property, will i still be able to access the userform, or is "lost" way beond the monitors reach?

    Also, are you using .activate or .initialize event to set up your form in the first place?
    To show the userform:

    Private Sub CommandButton4_Click()
    UserForm4.Show
    End Sub

    I tried swapping .Show with .Initialize, but i got a Compile error: Method or data member not found

    Thanks again

  5. #5
    Board Regular Weaver's Avatar
    Join Date
    Sep 2008
    Posts
    5,196
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Contain information in userform

    Sorry, I wasn't refering to how you opened the form

    When a form is opened, it triggers certain events, such as those I mentioned. The code will be in the form itself. Some developers use these events to prime their forms with certain values, such as populating a list box.

    so you might get
    Code:
     
    Private Sub UserForm_Activate()
        txtOp = 0
        chkDbar = False
        chkBackup = True
    end sub
    for example. I figured you were doing this, but with an initialize event, since usually just hiding a userform doesn't reset its values, they only get reset when reinitializing, and then only through code.

    If you change the .top property, you'll need to reset it, this is something you could do with the commandbutton code. So if you'd set it to 100 previously, the commandbutton code could set it back to 200 or whatever you're comfortable with.
    If the above suggestion contains vb code and you're not sure about using macros,check the following links (which in no way should be interpreted as being specific to your individual query):

    http://www.mrexcel.com/articles/past...o-into-vbe.php

    You can find help with array formulas here:

    http://www.cpearson.com/excel/arrayformulas.aspx

    If you really want to learn Excel, don't always accept the first solution.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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