+ Reply to Thread
Results 1 to 6 of 6

Bug evading me in showing multiple userforms

  1. #1
    Registered User
    Join Date
    09-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    9

    Bug evading me in showing multiple userforms

    Greetings all, long time viewer first time poster. Been teaching myself VBA for the last month.

    I have a userform with some dropdowns that populate from a worksheet. When the user clicks Go, if the first dropdown matches a specific string ("Failed Attack") then a second userform is launched. When the user clicks Go on the second form, I want control to return to the sub in the first form. This was working for me yesterday, but I added some code (not much, nothing that I can remember that would cause the error) and now the following happens:

    When the second userform is launched, and the user clicks OK on it, I get an Error 91 (Object variable or with block variable not set). Clicking debug highlights the show command for the second userform. This is confusing to me, because I assume that since the second userform is displayed, the code should go to the next line.

    Below is the code for when you click Go on the first userform (called ufCloseWizard):

    Please Login or Register  to view this content.
    This is the code for when the user clicks Go on the second userform (ufFailedAttack):
    Please Login or Register  to view this content.
    All the Close* variables are publically defined in a regular module, and CLOSEMASTERWB and CLOSEMASTERWS are defined as public constants in a regular module.

    This is the code when the second userform is loaded (in case its relevant):
    Please Login or Register  to view this content.
    Thanks in advance for any clues to this mystery! The data I'm working with is confidential so I cannot post the actual worksheets, but I'll be here for another 7 hours and am more than happy to try any suggestions.
    Last edited by zaimor; 11-06-2013 at 01:19 PM. Reason: Solved.

  2. #2
    Registered User
    Join Date
    09-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Bug evading me in showing multiple userforms

    Managed to figure it out. On a hunch, changed UserForm_Initialize to UserForm_Activate (and removed the .Show) and it worked. I'm still curious why I didn't get any other errors during previous tests with adding items to cbReasonFA during initialize? (because I'm assuming that's where the error actually lies... either that, or hiding the other labels/comboboxes)

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

    Re: Bug evading me in showing multiple userforms

    Try changing your Error Trapping level under Tools>Options...

    That should help when trying to locate errors in userform code.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    09-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Bug evading me in showing multiple userforms

    Norie: Thanks for that advice, but I don't see it listed under Tools > Options. Is there another name it might go by or another location for the option? I'm using Excel 2010.

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

    Re: Bug evading me in showing multiple userforms

    It's Tools>Options... in the VBE.

    You'll find Error Trapping on the General tab.

  6. #6
    Registered User
    Join Date
    09-12-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Bug evading me in showing multiple userforms

    Ahh, found it, thanks!

+ 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. Multiple userforms
    By 1976dan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2013, 09:52 PM
  2. Printing multiple userforms
    By ya7omar in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-29-2009, 08:58 AM
  3. userforms showing and hiding
    By Laurin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2005, 02:10 PM
  4. Multiple Identical UserForms
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2005, 02:10 AM
  5. simple yet evading
    By Colonel Flagg in forum Excel General
    Replies: 4
    Last Post: 05-11-2005, 11:06 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