• Closing one form closes the application (2002 (10.6771.6735) SP3)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Closing one form closes the application (2002 (10.6771.6735) SP3)

    Author
    Topic
    #430646

    I have a multi form application that I’m adding to. I’ve just added a form that is working correctly except that when I close it; It closes all other open windows . I’m not sure what to look for to correct this. I’ve looked at the form properties versus those of a form that closes correctly and can’t see any difference. There is a lot of VBA code behind my forms. It doesn’t matter if I close the form via code or the close button; it still shuts down all the windows.

    Any help would be appreciated. Thanks in advance.

    Mary

    Viewing 5 reply threads
    Author
    Replies
    • #1006134

      First, check what code (if any) the new form has in its On Close and On Unload events. If that doesn’t help, I would create the form anew, and/or import all database objects into a blank new database.

    • #1006137

      Does it just close all open windows and leave the database active or all open windows and also exit the database? If you cant find any code causing this in the on close or other events of the form then I would suggest re-creating the form by creating a new form and copying the data from the old form over to it.

      • #1006138

        It closes all forms and leaves the database open. I have code in the Open_form module and in a button click module. No code in the close module. I can, of course, re-create the form but would like to not have to.

    • #1006151

      Also check the code that opens the form (assuming you’re opening it from another form).

    • #1006154

      I copied the code to notepad and then deleted the offending form and re-created it from scratch. Copied the code back to the new form. And, you guessed it, nothing changed. When the form closes they all close.

      This is a really simple form: one combo box, one to three text boxes and a control button. I’m including the code here:

      Very long piece of code moved to attachment by HansV

      Thanks in advance,

      Mary

      • #1006166

        Could you post a stripped down copy of your database? See post 401925 for instructions.

      • #1006192

        The code you posted includes the following statement at the end.

        DoCmd.Close acForm, “Substitute”

        Did you check the code on any events that trigger when the form Substitute closes? I am assuming the code you posted is from the current active form, Not form Substitute.

        Also – What code does the Call statement trigger?

        • #1006195

          The DoCMd Close acForm, “Substitute” is in the Substitute Process_Click module. The plain DoCmd acDefault did not close the form.

          The call statement calls a subroutine (used from other forms and works correctly) which prints badges using a report. This subroutine does not close any forms.

          I’ve tried to shrink my application to under 100KB and am not having any luck. The forms themselves that are needed to get to the trouble area are almost 4MB in size. I’m trying to put them in different databases to see if I can get it under the limit.

          Thanks for the help,

          Mary

    • #1006199

      I was able to get my database into 2 zip files. This first one is the data.

    • #1006200

      The second file contains the forms, queries, module and reports. I had a large graphic in the first form that was making it too big.

      I’m getting an error I don’t understand on the 3rd form that I don’t get in the ‘big’ version. It’s not giving me the option of ‘dim dbs as Database’. Hopefully this is something someone knows how to quickly solve.

      To test this code:

      Click the Registrant button on the Expo 2006 startup form.
      Type in hie in the combo box and it will pull up hiebert, mark
      tab to the CONFIRM button and click or enter
      Click on the Seminar Registration button
      Click on the Substitue button
      Type an ‘a’ in the combo box and the name arevalo, luisa will show
      Click the Process button

      If the DoCmd Close is uncommented, then the form and all the open forms are closed. If the DoCmd Close statement is commented out the form stays there and when closed manually closes all the other open forms.

      Appreciate your taking a look.

      Thanks,

      Mary

      • #1006205

        You close forms in too many places, and as a consequence, the database window becomes the active window at some point. The line

        DoCmd.Close acDefault

        then closes the database window. In the first place, I don’t think you should try to close one form from another, this leads to unpredictable situations unless you think it all through very carefully. In the second place, you shouldn’t use the above line. Instead, use

        DoCmd.Close acForm, Me.Name

        when you want to close the form running the code.

        • #1006211

          That did it! Thanks so much. I went back and took all the docmd Close for other forms out and put in the docmd close acform,”form name” where it needed to be and it works great.

          Thanks again!

          Mary

    Viewing 5 reply threads
    Reply To: Closing one form closes the application (2002 (10.6771.6735) SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: