+ Reply to Thread
Results 1 to 11 of 11

Switching Forms in VBA

  1. #1
    Registered User
    Join Date
    11-11-2018
    Location
    Riga, Latvia
    MS-Off Ver
    office 365
    Posts
    5

    Question Switching Forms in VBA

    I have 2 forms created and one of the forms has a button to switch to another form.
    The code for that button looks like this:
    Please Login or Register  to view this content.
    client1 being the initial form to be opened and author being the next form to be shown.
    I have searched high and low for a solution with this, but for some reason this just doesn't work for me.
    Other things i also tried - Unload Me, Me.Hide.
    In all cases it just gives the message
    Capture.PNG

    Please, tell me what i am doing wrong.
    Last edited by 6StringJazzer; 11-11-2018 at 11:10 AM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Switching Forms in VBA

    Hi & welcome to the board.
    Do you have a commandbutton called "author"

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Switching Forms in VBA

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Which form has the "author" button?
    Which module contains the code you showed?
    When you get the compile error what line of code is highlighted?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Switching Forms in VBA

    Hi, and welcome to the forum,

    It's not clear exactly where these procedures are.

    Would you upload the workbook so that we can check in the context of the workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    11-11-2018
    Location
    Riga, Latvia
    MS-Off Ver
    office 365
    Posts
    5

    Re: Switching Forms in VBA

    Ah, sorry, i am still new to this whole VBA thing (and thank you for not destroying me for not reading the rules, i will get right on that).
    As to the questions:
    client1 has the "author" button.
    i do not know which module contains the code, because i just double clicked the button and it took me to... well... somewhere and there are Private Subs with which i am working.
    The
    Please Login or Register  to view this content.
    gets highlighted.

    here's also how the whole thing i am working on looks.
    Capture.PNG
    Last edited by milkfox; 11-11-2018 at 01:07 PM. Reason: didn't upload the picture

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Switching Forms in VBA

    The problem is that the button & the other userform have the same name, so VBA is getting confused.
    Either change the name of the button, or the name of the "author" userform.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Switching Forms in VBA

    Also remember that there's a difference between hiding a form and unloading it.

    Both will take the form off screen but if it's merely hidden it's still available and if its ShowModal property is not set to False then you won't be able to open another form.

  8. #8
    Registered User
    Join Date
    11-11-2018
    Location
    Riga, Latvia
    MS-Off Ver
    office 365
    Posts
    5

    Re: Switching Forms in VBA

    Quote Originally Posted by Fluff13 View Post
    The problem is that the button & the other userform have the same name, so VBA is getting confused.
    Either change the name of the button, or the name of the "author" userform.
    Thank you very much! That helped!

  9. #9
    Registered User
    Join Date
    11-11-2018
    Location
    Riga, Latvia
    MS-Off Ver
    office 365
    Posts
    5

    Re: Switching Forms in VBA

    Now i have a new question. How do i mark this post as solved?

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Switching Forms in VBA

    Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Switching Forms in VBA

    Quote Originally Posted by milkfox View Post
    Thank you very much! That helped!
    You're welcome & thanks for the feedback

+ 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. Avoid Switching Sheets, Reference Sheet Without Switching Instead.
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2017, 06:59 PM
  2. Replies: 0
    Last Post: 07-16-2015, 07:51 AM
  3. Switching between user forms
    By Lokesh_g in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2010, 06:57 AM
  4. Print on ready blank forms (document forms)
    By gandrinno in forum Excel General
    Replies: 1
    Last Post: 02-16-2009, 06:12 PM
  5. switching between two forms of measurement
    By Don Juan in forum Excel General
    Replies: 1
    Last Post: 03-02-2007, 07:02 AM
  6. Switching Forms
    By GogsJames in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-14-2006, 04:42 AM
  7. [SOLVED] Excel forms - authorise / deny forms
    By Ian Manning in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2006, 12:10 PM

Tags for this Thread

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