Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error Closing subForm with OLE Charts (Office 2K)

    Before I create an example MDE, I thought I'd ask if anyone else has experienced a similar problem, and if so, suggest a work-around:
    I have a main form with a listbox and a subform, both of which occupy the same real estate, but only one at a time is visible. Using the listbox, I select a specific chemical solution. The resulting VBA code sets the listbox invisible, copies the autonum key (obtained from the listbox selection) for the solution into a subform field and also generates a SELECT statement to obtain solution characteristics for the selected solution (PH, Specific Gravity, etc) from a different table. The generated SELECT statement is copied into the RowSource field of another listbox within the subform. I then set the subform visible. While in the subform, I provide the user the ability to display the listed solution characteristics in graphical form, rather than the tabular form created by the generated SELECT statement. This is accomplished by predefining the graph(s) using the forms Chart Wizard, then copying (in design mode) the resulting graphic control into the correct location of the subform. The subform normally keeps the graphic invisible, unless the user requests to see it. I then rebuild the RowSource SQL statement for the graphic control with an additional WHERE clause to isolate the specific solution rows for graphic consideration. This all works quite nicely.

    The problem arises when I go to close down the form/subform. When I click on the close button for the form, its Close Event is entered, and successfully completed. However, between the time the form Close Event exits, and the subform Close Event is entered, I get the following popup message from Access:

    The object is locked, so any changes you make will be discarded when the form is closed.
    Click Save As/Export on the File menu and save the object under a different name.
    (followed by an "OK" box)

    I get a repeat of this message box for each open graphic control; so I'm pretty sure it is referring (somehow) to the OLE graphic control(s), even though the message fails to identify which object it thinks is locked. Since I don't explicitly lock anything within any of the graphic controls, I am at a loss as to what is causing this message, and/or how to suppress it.

    Any insights will be greatly appreciated.
    -- Jim

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

    Re: Error Closing subForm with OLE Charts (Office 2K)

    See if you can avoid the messages by putting a command button on the main form with caption 'Close' and the following On Click event procedure:

    Private Sub cmdClose_Click()
    DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub

    where cmdClose is the name of the command button. It's best to set the Close Button property of the main form to No, so that the user will be more likely to use the command button to close the form. (If your form is maximized, you need to do more.)

  3. #3
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Closing subForm with OLE Charts (Office

    Well, Hans, it was a good suggestion (doing the explicit close with "acSaveNo". However, the results are still the same:

    1. Enters the main form Close Event code and runs to exit successfully.
    2. Returns to just after the "DoCmd.Close acForm, Me.Name, acSaveNo" command and exits that Click function.
    3. Gets the popup messages as described above.
    4. Enters the subform Close Event code and runs to exit successfully.

    By the way, I do not run the form maximized.

    Any other thoughts?

    -- Jim

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

    Re: Error Closing subForm with OLE Charts (Office

    Are you opening the form or subform in design mode from code?

  5. #5
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Closing subForm with OLE Charts (Office

    No. I've never even thought of a good reason to do something like that. Is this a case where it could be useful?

    -- Jim

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

    Re: Error Closing subForm with OLE Charts (Office

    I didn't mean to suggest that you should use that method here. You should avoid it where possible. I asked about itr because it might have been a possible explanation for the messages you get. I use the method of changing the row source of chart objects extensively in one of my databases without getting this message, so I don't know why you get it.

  7. #7
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Closing subForm with OLE Charts (Office

    OK. I guess I'm going to have to build a stripped down MDB and post it for further examination. Undoubtedly, the problem will disappear in doing that! <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    BTW, I've tried explicitly setting the Lock property of the four graphic controls to False. No change. I also tried setting their RowSource string to a zero-length string. Also, no change.

    I'll be back with the MDB later.

    Thanks, Jim

  8. #8
    Star Lounger
    Join Date
    Jan 2003
    Location
    Grass Valley, California, USA
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error Closing subForm with OLE Charts (Office

    Well Hans, I've learned a lot. In the process of attempting to build the example MDB file, I discovered that I took the book's examples a bit "too literal". The book examples show how to build a chart with the Forms Chart Wizard, which I did, but of course builds it in a new form. I did that and then did a cut & paste to place the OLE chart control over into the actual form in which I wanted it. That all works, as I've documented above. However, that is the process which lead to the error messages, as well.

    However, today, I deleted those chart/graph controls from the real form, then rebuilt them in the form directly using the menubar "Insert Chart" selection. As I'm sure you (and other readers) have guessed by now, all my problems disappeared. Everything now works as hoped and expected.

    Thanks for making me dig a bit deeper. This is one more of those "live & learn" experiences.

    -- Jim

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

    Re: Error Closing subForm with OLE Charts (Office

    I'm glad you were able to solve it yourself.

Posting Permissions

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