Results 1 to 8 of 8

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

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    2

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

    "Runtime Error '401': Can't show non-modal form when modal form is displayed." keeps showing up in my program in VB. In the editor it runs fine, but on launching the EXE the error comes up. I´ve looked online and can´t find much info. Does anyone have any suggestions?

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,548

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

    From the error you have a form displayed as modal and while that form is displayed your code is trying to show a non modal form. If it is not happening in the IDE then my first thought would be that you are showing a non modal form in a timer either that or you just haven't met the same conditions in the IDE.

    Check any timer based code for any code that shows it sets visible to true on some other form.

  3. #3
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,457

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

    This may not help, but who knows.
    When running in the IDE, run it with full compile.
    That little trick can reveal some errors, thus I always run my program with this keyboard shortcut
    Hold down the ALT key and type fsrf
    That saves the current open form(and code window) fs and runs with full compile rf

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,548

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

    It sounds like the exe was created which means full compile will not catch the error.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    2

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

    Quote Originally Posted by DataMiser View Post
    From the error you have a form displayed as modal and while that form is displayed your code is trying to show a non modal form. If it is not happening in the IDE then my first thought would be that you are showing a non modal form in a timer either that or you just haven't met the same conditions in the IDE.

    Check any timer based code for any code that shows it sets visible to true on some other form.
    I do have one Timer Based Visible code, its for a loading bar. Is that the problem?

  6. #6
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,534

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

    Maybe you should share some code, especially the parts in which you open and show the forms

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,548

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

    If there is any code executing that tries to make a non modal form visible while a modal from is active you will get this error.
    I can't be sure what you mean by loading bar but if it is a form with a progress bar that is not shown as modal and is triggered while the modal form is active then yes that would cause the error you mention.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,352

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

    are you running the ide elevated and the exe as standard?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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