• Database won’t close? (Access 97 SR2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Database won’t close? (Access 97 SR2)

    Author
    Topic
    #372112

    I don’t know what I did to my database…..

    I close all the forms, the container window (with all the objects) is still open, and I click on the close button at the top of the database. Shouldn’t this completely close the database?

    What I get is the access frame open, but the container window is closed. The access frame won’t close at all. The only way out of this situation is [End Task] on Access.

    I also have a button on the main form that has the code DoCmd.Quit. This does not close the Access frame either.

    Does anyone know what I did & how to correct it? It’s making me looney.

    TIA!

    Cecilia smile

    Viewing 0 reply threads
    Author
    Replies
    • #593740

      This is usually caused by objects that were set in your code but not destroyed. Setting a recordset object, for example, and not closing it and setting it to nothing or setting a querydef object and not destroying it. Try scouring your code for those kinds of things first. If that fails you, post back. I seem to recall a couple of other reasons for this, including not using specific comparisons in statements like this:

      If Me!txtOK Then …

      Instead of

      If Me!txtOk = True Then

      • #593833

        Hi Charlotte,

        Well, I’ve been pretty consistent about destroying objects. I’m checking the If statements now, how in depth do I need to go?

        For instance, is
        If IsNull(Forms!frmData.cboDivision)
        okay, or do I need to change it to
        If IsNull(Forms!frmData.cboDivision)=True
        and similarly
        If IsMissing(strDivision)
        These are all over the help files.
        The other one I have is If rst.NoMatch, should this be If rst.NoMatch=True?

        TIA!

        Cecilia 🙂

        • #593839

          I’m *very* consistent about it, and I’ve been bitten by this, so check just to be sure. Querydef objects are easy to overlook because the really should go out of scope when the code container they’re in is closed. Unfortunately, the isn’t always the case.

          You only need to use the “= True” when the control’s value itself evaluates to a boolean. The other method is to wrap the control reference in parens, which forces it to be evaluated. For instance, if you have a checkbox on a form, you might expect it to return a boolean value and skip over the rest of the expression, but it’s risky. It should be:

          If Me!chkMyCheckBox = True …

          Or

          If (Me!chkMyCheckBox) Then …

          not just

          If Me!chkMyCheckBox then …

          Using functions like IsNull gives you a boolean value because that’s what they return.

    Viewing 0 reply threads
    Reply To: Database won’t close? (Access 97 SR2)

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

    Your information: