+ Reply to Thread
Results 1 to 21 of 21

VB Code to Call Userform in Userform

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    VB Code to Call Userform in Userform

    Greetings!

    Hello, I wonder if what code should I use to call another userform inside a userform. It keeps prompting me an error when I tried to insert a userform.show in a click event. here is the example.

    this is the code to call the main userform

    Private Sub CommandButton4_Click()
        frmSRStat.Show
    End Sub
    then this userform will appear.

    Attachment 146862

    here is the code for this main userform

    Private Sub cmdClose_Click()
        Unload Me
    End Sub
    
    Private Sub cmdSelect_Click()
    Sheets("Group SR").Range("N1") = ComboBox1.Value
    If ComboBox1.Value = "ALL STATUS" Then
    Sheets("Group SR").Range("N1") = ""
    End If
    Unload Me
    End Sub
    
    Private Sub Image1_Click()
    frmCalendar.Show
    End Sub
    
    Private Sub TextBox1_Change()
    Calendar1.Value
    End Sub
    
    Private Sub UserForm_Initialize()
    With ComboBox1
        .Value = "ALL STATUS"
        .AddItem "ALL STATUS"
        .AddItem "ACTIVATED-CONFIRMED"
        .AddItem "ACTIVATED-QA"
        .AddItem "ESCALATED NPSD SOC BRO"
        .AddItem "ESCALATED NPSD SOC BRO - PREMIUM"
        .AddItem "ESCALATED_NPSD_CRG"
        .AddItem "ESCALATED-KSP"
        .AddItem "FEEDBACK"
        .AddItem "FOR_DEPLOYMENT"
        .AddItem "FOR_RESCHEDULING"
        .AddItem "OPEN"
        .AddItem "SCHEDULED-RESCHEDULED"
    End With
    End Sub
    then in escalation date field. i will click the small calendar image so that the second userform will appear. but upon clicking, it will prompt me an error that says object required.

    Attachment 146861

    i tried to insert the line frmCalendar.Show(name of the second userform) in Private Sub Image1_Click() event then the error now prompts. I don't know how to call the second userform inside the main userform.
    Last edited by Stonesteel15; 03-22-2012 at 04:29 AM.
    "Consummatum Est"

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    Check to see if the properties of the userforms > Show Modal is set to false.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    Show Modal is all set to True.

    perhaps if you could try to open the workbook and execute the codes, maybe you could help me identify what is the problem.

    Attachment 146867

  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: VB Code to Call Userform in Userform

    Hello Stonesteel15 ,

    You will need to repost your workbook without the VBA Project being protected.
    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!)

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    Hello Stonesteel15 ,

    Please see if the WorkBook now does what you want.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    Quote Originally Posted by Winon View Post
    Hello Stonesteel15 ,

    Please see if the WorkBook now does what you want.
    Hi Winon, your code works, may I ask what in those codes did you changed for the calendar to show? upon comparing, there seems no change in the code. also i forgot to ask, what code should I use in the textbox so that when I changed the date, the value in the textbox will also change.

  7. #7
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    Quote Originally Posted by Stonesteel15 View Post
    Hi Winon, your code works, may I ask what in those codes did you changed for the calendar to show? upon comparing, there seems no change in the code. also i forgot to ask, what code should I use in the textbox so that when I changed the date, the value in the textbox will also change.

    OK I got it, it seems that the changes made was in the Initialize part of the code, and also I got to make the date appear in the textbox whenever I select date.

    Thank You guys for the assistance. You are such a big help to the community :D

  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: VB Code to Call Userform in Userform

    See my calendar form example here, it has an example of what you want
    Hope that helps.

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

    Free DataBaseForm example

  9. #9
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    Quote Originally Posted by royUK View Post
    See my calendar form example here, it has an example of what you want
    Hi royUK, hmm thank you for the suggestion but as much as possible I don't want to insert add ins to the workbook since I will be disseminating this workbook to the company. and not all users had a permission to modify their workstations.

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

    Re: VB Code to Call Userform in Userform

    I wasn't referring to the addin, the CalendarForm example is what I meant

  11. #11
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    oh shoots, I'm sorry, I didn't notice the sentence describing the form. :D

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    Hello Stonesteel15 ,

    I would gladly assist as far as I can, but the vba project is password protected, and I cannot go any further than what I had sent you. As Leith Ross has asked,
    You will need to repost your workbook without the VBA Project being protected
    or you will have to send me the Password.

  13. #13
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    oh wait, I didn't notice it, and can I request again. I thought it was finished already but I still have another problem, the textbox is displaying the date I selected, yes, but when I close the form and open it again, the value in the textbox return to the current date, can you guys assist me how to edit that part, that when I close the form and when I opened it again, the value in the textbox should be the date what I selected before. here is the form.

    Attachment 146882

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: VB Code to Call Userform in Userform

    hi
    try this..
    Private Sub UserForm_Initialize()
        With ComboBox1
            .Value = Range("N1")
            .AddItem "ALL STATUS"
            .AddItem "ACTIVATED-CONFIRMED"
            .AddItem "ACTIVATED-QA"
            .AddItem "ESCALATED NPSD SOC BRO"
            .AddItem "ESCALATED NPSD SOC BRO - PREMIUM"
            .AddItem "ESCALATED_NPSD_CRG"
            .AddItem "ESCALATED-KSP"
            .AddItem "FEEDBACK"
            .AddItem "FOR_DEPLOYMENT"
            .AddItem "FOR_RESCHEDULING"
            .AddItem "OPEN"
            .AddItem "SCHEDULED-RESCHEDULED"
        End With
        Me.TextBox1.Value = Range("L1").Value
    End Sub
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  15. #15
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    There you go!
    Attached Files Attached Files

  16. #16
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    @ john55,

    Its been a while. Nice to have you on board here as well.

  17. #17
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    Quote Originally Posted by Winon View Post
    There you go!

    got it, thank you very much Winon.

  18. #18
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    thanks john, I was about to post that I already got it, and we have the same solution. Thank you guys, thank you guys.

    Private Sub UserForm_Initialize()
        With ComboBox1
            .Value = Range("N1")
            .AddItem "ALL STATUS"
            .AddItem "ACTIVATED-CONFIRMED"
            .AddItem "ACTIVATED-QA"
            .AddItem "ESCALATED NPSD SOC BRO"
            .AddItem "ESCALATED NPSD SOC BRO - PREMIUM"
            .AddItem "ESCALATED_NPSD_CRG"
            .AddItem "ESCALATED-KSP"
            .AddItem "FEEDBACK"
            .AddItem "FOR_DEPLOYMENT"
            .AddItem "FOR_RESCHEDULING"
            .AddItem "OPEN"
            .AddItem "SCHEDULED-RESCHEDULED"
        End With
        With TextBox1
            .Value = Range("L1").Value
        End With

  19. #19
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: VB Code to Call Userform in Userform

    hello guys,
    Stonestell15, I did not know that you already have it!
    Winon, hehehehhe... how r u?
    sorry man, I did not see you r online! ...too many unknown things!

  20. #20
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: VB Code to Call Userform in Userform

    I am marking the thread as [SOLVED]

    thank you guys for your big help.
    Last edited by Stonesteel15; 03-22-2012 at 04:28 AM. Reason: Marking as Solved

  21. #21
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VB Code to Call Userform in Userform

    You are welcome!

+ 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