2 forms
Results 1 to 5 of 5

Thread: 2 forms
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,303
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default 2 forms

    Hi
    I have 2 forms. UserForm1 and UserForm2. Do I need to say
    UserForm2.Label1.Caption
    or just
    Label1.Caption

    I did "Label1.Caption" and everything work fine, it is not effecting the UserForm1

    The code below is for UserForm2
    Code:
    Private Sub myadd_Click()
    UserForm2.Label1.Caption = UserForm2.Label1.Caption + 1
    End Sub
    
    
    Private Sub mysub_Click()
    Label1.Caption = Label1.Caption - 1
    End Sub

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    26,897
    Post Thanks / Like
    Mentioned
    459 Post(s)
    Tagged
    45 Thread(s)

    Default Re: 2 forms

    Quote Originally Posted by lezawang View Post
    Do I need to say
    UserForm2.Label1.Caption
    or just
    Label1.Caption
    You just answered you own question
    I did "Label1.Caption" and everything work fine
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,706
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: 2 forms

    If you are in the form2 and you have open the form1 and you want to affect the form1 from the form2, then:

    Code in form2
    Code:
    Private Sub myadd_Click()
    UserForm1.Label1.Caption = UserForm1.Label1.Caption + 1
    End Sub
    Regards Dante Amor

  4. #4
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,303
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 2 forms

    Ok I got it now why I need to mention that. Thank you all for the help. I appreciate it.

  5. #5
    Board Regular DanteAmor's Avatar
    Join Date
    Dec 2018
    Location
    México
    Posts
    5,706
    Post Thanks / Like
    Mentioned
    65 Post(s)
    Tagged
    14 Thread(s)

    Default Re: 2 forms

    You're welcome and thanks for the feedback.
    Regards Dante Amor

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
  •