Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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.

  3. #3
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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.
    Regards,

    Gary
    (It's been a while!)

  4. #4
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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.

  5. #5
    Star Lounger
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

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

  6. #6
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  8. #8
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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?
    Regards,

    Gary
    (It's been a while!)

  9. #9
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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

  10. #10
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

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

  11. #11
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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.

  13. #13
    Lounger
    Join Date
    Mar 2001
    Location
    Texas
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing one form closes the application (2002 (10.6771.6735) SP3)

    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

Posting Permissions

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