Results 1 to 6 of 6

Thread: RESOLVED[Userform1 to userform2]

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved RESOLVED[Userform1 to userform2]

    I have 2 userforms. In userform1 I entered some data through a combobox and stored it in a variable defined as a string. Then from userform1, once you've finished filling it, you pass to userform2.
    How can you bring to userform2 the data from the combobox in userform1 stored in that variable?
    Last edited by Fonty; May 23rd, 2006 at 02:58 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Userform1 to userform2

    Place the variable declaration in a Module. Make it Public blah As String and it will be afvauilable to any userform or sheet.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Userform1 to userform2

    I created a module with:
    VB Code:
    1. Sub region()
    2. Public region As String
    3. End Sub
    However, when I put in the userform
    VB Code:
    1. region= cboRegion.Value
    it happens to be an error. What am I doing wrong?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Userform1 to userform2

    Should be like this ...
    VB Code:
    1. Option Explicit
    2.  
    3. Public strRegion As String
    Then to use anywhere:


    VB Code:
    1. Private Sub Command1_Click()
    2.     strRegion = "West Side!"
    3.     MsgBox strRegion
    4. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Re: Userform1 to userform2

    Sorry... I still don't get it. Where do I write Option Explicit?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Userform1 to userform2

    In a new standard Module. You can add it to your project if you dont have one by right clicking on the project file in the VBA IDE Project explorer and selecting Insert Module.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width