+ Reply to Thread
Results 1 to 12 of 12

UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to 2

  1. #1
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to 2

    Hi There...

    I have UserForm1 where the employee must enter his details in "Textbox_Employee" and then select a certain machine in "Textbox_MachineAlocation". Based on the selection from the "Textbox_MachineAlocation" entry from UserForm1, it must then open the required UserForm for the specific machine (Such as userforms called MachineCalibration1, MachineCalibration2 or MachineCalibration3 etc.) and must also close UserForm1. It must also transfer the entry from (UserForm1 - "Textbox_Employee" & "Textbox_MachineAlocation") to the Userform that will be opening.

    The code below is opening a certain UserForm but it must however be selected from the TextBox entry.
    Please Login or Register  to view this content.
    I have tried this code but could not get it to work.
    Please Login or Register  to view this content.
    Any idea how to do above?

    Also how do I get UserForm1 to close? Below code only hides it.
    Please Login or Register  to view this content.
    Here I have tried the following but it does not work.
    Please Login or Register  to view this content.
    Anyone knows how to achieve this?

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Hi Colin,

    To close UserForm1 that was opened with the 'UserForm1.Show' command
    Please Login or Register  to view this content.
    The following code from the attached workbook should help you get started associating variable names with UserForms:
    Please Login or Register  to view this content.
    Lewis

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

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    LJMetzenger's Userforms.Add method won't work on Macs.

    In any case, I'd suggest a combo box rather than a text box to avoid misspelling errors.

    If you put code like this in the main user form, it should work.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Quote Originally Posted by LJMetzger View Post
    Hi Colin,

    To close UserForm1 that was opened with the 'UserForm1.Show' command
    Please Login or Register  to view this content.
    The following code from the attached workbook should help you get started associating variable names with UserForms:
    Please Login or Register  to view this content.
    Lewis
    Thank you for the reply and the sample file. It works!

  5. #5
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Quote Originally Posted by mikerickson View Post
    LJMetzenger's Userforms.Add method won't work on Macs.

    In any case, I'd suggest a combo box rather than a text box to avoid misspelling errors.

    If you put code like this in the main user form, it should work.

    Please Login or Register  to view this content.
    Thank you for your reply and post as well as the sample. I have decided to go with this option because some of the names are a bit tricky. It was my idea from the start to use a combobox due to the possibility of a mistype. I must admit that with a sample it is much easier to see where I went wrong. Again thank you both of you for taking the time to compile a sample as well. I appreciate it! I will now mark this thread as solved!

  6. #6
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Quote Originally Posted by mikerickson View Post
    LJMetzenger's Userforms.Add method won't work on Macs.

    In any case, I'd suggest a combo box rather than a text box to avoid misspelling errors.

    If you put code like this in the main user form, it should work.

    Please Login or Register  to view this content.
    Above code I got to work 100%. I have however identified a problem on my part. The machines to be calibrated are dependant on the specific calibration form. The problem is that some of them have a complex name. The only way to have the user form opening is by renaming it to this machine name and herewith the problem. Some of them are called..."Work Area 7, Mixer Number:3 (Reclaimed Sand)" A user form cannot be renamed to this type of name. Is it [possible to have each of the selections in the combobox1 referring to a certain user form name?

    I have tried below code with no success.
    Please Login or Register  to view this content.
    Do you know how to do this?

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Hi Colin,

    Thanks for the rep points.

    The simplest way would probably to have simple names for the UserForms. The captions on the UserForms can be changed to display whatever text you like. See the attached working file, which uses Mike's code as a baseline, since your previous post used Mike's code.

    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Quote Originally Posted by LJMetzger View Post
    Hi Colin,

    Thanks for the rep points.

    The simplest way would probably to have simple names for the UserForms. The captions on the UserForms can be changed to display whatever text you like. See the attached working file, which uses Mike's code as a baseline, since your previous post used Mike's code.

    Please Login or Register  to view this content.
    Lewis
    Thanks a Lot!! Code works exactly as I need it to work. I would have never thought to have changed it in that way. Reason why I went for Mike's form was due to it also being used on Mac. Thank you again for all your work and sample file. I appreciate it!

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

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    In my code the correspondence between ComboBox entry and user form name is arbitrary. The Select Case in SelectedForm can be expanded to
    Please Login or Register  to view this content.
    (The Intiialize event will have to be changed to add the item "Special Calibration Alpha 95")

    LJMetzger, thanks for catching the lcase requirement.
    Last edited by mikerickson; 12-07-2014 at 01:11 PM.

  10. #10
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Thank you to both of you for all the help. I am now able to select the required user form as required. One last thing I am trying to achieve (With no results thus far) is to have the combox1.Value to display in the second user form that opens. I have 19 different machines that uses 5 different user forms. In other words the same user form can be utilized for example on 5 different machines. The calibration completed will however be on that selected machine. So I would like the selection from combobox1 on the first user form to display on the TextBox1 on the second User Form that opens.

    I have tried to copy to a cell on a sheet but that value only updates once the second user form is closed. Is there a way for the value to transfer to the second user from that opens when the first one closes?

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Have you tried this?
    Please Login or Register  to view this content.
    That would go before the code to show SelectedForm.

    Or you could put this in the Initialize event of each of the calibration forms.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  12. #12
    Forum Contributor
    Join Date
    06-03-2014
    Location
    South-Africa
    MS-Off Ver
    2010
    Posts
    133

    Re: UserForm1 to Open UserForm2 & close itself but transferring txtbox entry from Form1 to

    Please Login or Register  to view this content.
    That would go before the code to show SelectedForm.


    Thank you Norie. The code above did the trick. I placed it in the code below after the selected form was chosen from the Combobox1.Value.

    Please Login or Register  to view this content.
    Thank you for your help here as well. I realize that the post have been marked as Solved but never thought that there would be one or two more errors. If any new errors arise I will create a new post. I however do not think that there will be any more with regard to this post as everything works as it should now.

    Thank You to everyone for helping in this post. I have tried a few Excel Forums but none of them beats this one!
    Last edited by Colin Smit; 12-08-2014 at 02:37 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. UserForm2 Initialize Userform1
    By weeeee0713 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2014, 06:45 AM
  2. Cancel Button on Userform2 closes Userform1. Why?
    By biznez1 in forum Excel General
    Replies: 3
    Last Post: 07-29-2013, 03:08 PM
  3. [SOLVED] Transfer data from Userform1.listbox1 to userform2.listbox2
    By Vbadept in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2013, 08:28 AM
  4. transer the date from userform2 to userform1 testbox1
    By Jeff up North in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2013, 06:45 PM
  5. Display data entered on userform1 to userform2
    By stoey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-13-2008, 10:49 AM

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