dcsimg
Results 1 to 6 of 6

Thread: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2008
    Posts
    268

    "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    What causes this? I've looked into it, but not found very much information.

    It occurs when my app starts up and displays a splashscreen while loading another form.

    Thanks

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    17,465

    Re: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    The cause is pretty much what the error says.

    Once a modal form is shown, only way to show another form is
    1. Close/Hide all modal forms and then show the non-modal form
    2. Open every form thereafter as vbModal

    So the splash screen is being shown modal? If so, it must show the the other form as modal also or simply don't show the splash as modal. You will get this error also if the other form is trying to show itself while a modal form is displayed....

    Example:
    1. frmSplash.Show vbModal
    2. frmSplash then loads other form: Load frmOther <no error yet>
    3. in other form's Load event: Me.Show <error because frmSplash is modal>
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Member
    Join Date
    Sep 2006
    Location
    Didcot UK
    Posts
    35

    Re: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    This normally occurs when there's a Show instruction for the form that's loading before the end of the Form_Load event, in other words the end of the Form_Load event is trying to show the form that's already showing, causing the error.

    Ensure that the form is not visible at the end of the Form_Load event. If the form is required to be visible during loading for debugging purposes add an Me.Hide instruction at the very end of the Form_Load event.
    Homer: To start press any key. Where's the 'any' key?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2008
    Posts
    268

    Re: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    Gotcha.

    My frmSplashscreen form is the startup form. My frmMain form contains a webbrowser control. On the DocumentComplete event of my webbrowser in frmMain, it triggers this among other tasks:

    Code:
     frmMain.Show
     Unload frmSplashscreen
    Flipping those two around should solve the problem, correct?

    (Only some users of my product are receiving this error - I am not, so that's why I didn't just test to see myself)

  5. #5
    Member
    Join Date
    Sep 2006
    Location
    Didcot UK
    Posts
    35

    Re: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    Ooops, got my wires crossed ignore my advice above!!
    Homer: To start press any key. Where's the 'any' key?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2008
    Posts
    268

    Re: "Runtime Error '401': Can't show non-modal form when modal form is displayed."

    :P Ok, thanks guys

    As an interesting side note, it seems to be users that have custom XP themes who have this issue. Not sure if they're using something like WindowBlinds or the UXTheme patch.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width