+ Reply to Thread
Results 1 to 8 of 8

userform: trasnferring textbox value to label field in next userform

  1. #1
    Registered User
    Join Date
    05-03-2008
    Posts
    24

    userform: trasnferring textbox value to label field in next userform

    Hello

    I am creating a userform with a series of steps and command buttons. I want users to enter text for an ID # in the first pop-up (UserForm2). When they click NEXT (CommandButton1), I want the text/ID#(TextBox1, TextBox2,...TextBox6) to transfer into a label field (Label10,Label11,...Label15) in the next pop-up(UserForm1).

    I have also written code for the TextBox values to populate in a database worksheet so that I can refer to those values later.

    Can I write the code to transfer the text to the label in the same macro for CommandButton1?

    Here is the code for clicking NEXT(CommandButton1):
    Please Login or Register  to view this content.
    End Sub
    Last edited by Leith Ross; 07-17-2008 at 01:23 PM.

  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,258
    Hello brillison,

    You can change the labels when UserForm1 is activate as long as UserForm2 is still loaded.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-03-2008
    Posts
    24

    Red face wrapped code - my apologies

    My apologies for not wrapping the code. I inserted wrapped code below.


    Please Login or Register  to view this content.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Putting this in the first userform (UserForm2) code module will pre-load the second userform (UserForm1)
    Please Login or Register  to view this content.
    If UserForm1 is unloaded, this code will create an instance of UserForm1 (but not .Show it) and fill the labels' captions, so they will show when the line
    Please Login or Register  to view this content.
    is exicuted.

    If UserForm2 is already instanced, it will change the label's captions.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    05-03-2008
    Posts
    24
    I am not the greatest at these macros. But it seems wherever I put the code, it doesn't populate the text on UserForm1. I am sure i am doing something wrong. I have attached the excel worksheet.

    On Sheet 1, click "START POA&M COSTING" to start the macros.
    Userform2 pops up.
    Enter random text in each of the fields.
    Click NEXT
    Userform1 pops up blank.

    Thank you for all your help and patience!
    Attached Files Attached Files

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    My appologies, I thought that UF2 was being unloaded rather than hidden.

    This command button routine will put the data in UF1 labels
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-03-2008
    Posts
    24

    Thank You!!!!

    AWESOME!!!! It worked! Thank you so much for helping and training me!

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Glad to help.

    You might want to think about renaming the userforms and controls. A situation where UserForm2 calls UserForm1 can be confusing.
    Using the name field of the Properties window you could change the name of CommandButton1 to butNext or something that relates to the purpose or caption on the controls.

    Unfortunatly, the names need to match the names of the event routines, so you will need to change all the code to the new names. But six months from the end of the project, when you want to change something, meaningful control names will help you remember what you are did and how to modify.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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