Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mystery code running (A2k-SR1)

    Hi,

    Either my .mdb or myself has lost it's marbles !

    When I open a particular form (that I edited this morning) in design mode and immediately try and close it without making any changes, I get a prompt as to whether I would like to save the changes that have been made. If I select "no", then it closes OK the first time. If I then re-open it in design mode, it then refuses to let me close the form and gives the error message as shown in the attached image. It seems that merely loading the form in design mode has triggered some code, but I have no idea how this is possible. In any case the form doesn't have an "on load" event procedure. It does have "on current" and "after insert" procedures, but I cannot imagine that these are triggered by opening the form in design mode. If I flip over to VBA, no code is running and pressing the "reset" icon or "CTRL-Break " does nothing because there is no code running that I can tell.

    Clicking "yes" (to terminate the code) does nothing except beep and bring up the same error dialog. Clicking "no" takes me back to the form leaving me stuck anyway.

    After making the changes this morning, the form worked fine. It is a subform that is used on a main form. Opening the main form in design mode causes the same peculiar behaviour. I can't think of any additional changes that I made to the form code from the time that I tested the new code this morning when it worked fine until now.

    I saved the new code that I added this morning, deleted the offending main and subform, imported "clean" copies of the forms from my previous backup and then copied in the new code again. The problem persists.

    I decompiled the .mdb, repaired and compacted it and still the same problem.

    This strikes me as a bug, but maybe I am doing something stupid. Any ideas please ?

    TIA,
    Attached Images Attached Images

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Mystery code running (A2k-SR1)

    Is it possible that the form has already been opened, but is hidden from view? Although I've noticed that when I click the save button, Access will offer to save other forms which I don't think I made changes to.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mystery code running (A2k-SR1)

    Hi Mark,

    I don't think this is the case. After restarting my PC and going into Access, as soon as I load the offending form in design view the problem occurs.

    There is a "main menu" form that gets loaded on startup, but I have tried disabling that and the problem persists.

    I have tried re-inserting the code piece by piece and it seems that if the code for the "Got Focus" event of a combobox on the form is present, then the problem occurs.

    I haven't got to the bottom of this yet, but I have just looked at my back-end database to which this one is linked and I think this has become corrupted.

    Thanks for the suggestion - I'll keep digging,

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

    Re: Mystery code running (A2k-SR1)

    Hello Adrian,

    I think this is related to the thread "Referring to a field on a subform" you posted earlier.

    If the combo box is the first in the tab order of the form, it will get focus as soon as the form is loaded. The code in the OnFocus changes the RowSource property of the combo box. Access probably sees this as a design change.

    What I often do is put a command button on a form that closes the form without saving changes (to the design, that is):

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

    If you like, you can disable the close button in the top right corner of the form by setting the CloseButton property of the form to False. Users can still close the form by using Ctrl+F4, though - in that case, they will be prompted if they want to save changes.

    There is one caveat: if the user closes the form using the command button AND the current record hasn't been saved AND a problem occurs while saving the record, the form will be closed anyway, probably without an error message.

    Regards,
    Hans

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mystery code running (A2k-SR1)

    Hi Hans,

    Problem solved, it was definitely a corrupt database that was causing the problem. A single table was in-accessible !! I have no idea how that happened. I couldn't even delete the table, so I had to recreate the back-end by importing the other tables and then importing the faulty table from a back up.

    I have subsequently gone through all the security settings on all the db objects and made sure my workgroup members have the desired permissions. I don't know if this was causing a problem somehow. One thing I noticed was that the user's permissions on some of the objects didn't always match the permissions of the user group to which they belonged. It is as though they had only inherited some of their group permissions. I must make the time to read the Access Security FAQ that I got from TechNet.

    I presume that even in loading the form in design mode only, Access checks for data items on which the form depends. Since that table was destroyed, Access lost it's mind at that point.

    Regards,

Posting Permissions

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