• Sometimes OnDirty Event won’t fire (All)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Sometimes OnDirty Event won’t fire (All)

    Author
    Topic
    #446800

    I have some standard code I typically use in most forms. It just makes my “Save” and “Undo” buttons visible.

    On some occasions, I’ve noticed that my buttons didn’t become visible, and actually the OnDirty event was never firing. I narrowed it down to it being when I was adding a new record vs. modifying an existing record. But this was not a routine occurance; it didn’t happen with 99% of my forms, but every once in a while I had a form were it was a problem. I was always able to create a work-around, but it just annoyed me.

    I finally figured out the cause, and it may be something that others know about, but it was new to me.

    In the few times I had this problem, I also had code in my Before Insert event. Not just any code, but code that set the value of a field in the record! Why this should be a problem seems logical to me now, but first I had to understand 2 concepts:

    #1: Changing the value of a field in code will make the record dirty (if it isn’t already), but will not cause the OnDirty event to fire.

    #2: The Before Insert event fires before the On Dirty event.

    When I hit a keystroke on a “Clean” form, Access ran my Before Insert code. By changing a field in Before Insert, I made the form Dirty. But then when it came time to evaluate whether/not to fire the On Dirty event because of the keystroke, apparently Access said “The form was already dirty, so your keystroke didn’t dirty it! Therefore I won’t fire the On Dirty Event!”.

    Viewing 1 reply thread
    Author
    Replies
    • #1087396

      Thanks! dizzy

    • #1087630

      Since this post seems to be at the end of its thread, could I offer my 2cents piece of advice…

      Before you insert the round, or fire the event, ensure that the revolver is clean, that you have got the focus and that you do not have an on unload problem. On mouse move, trigger the event, and you will find the unload event works with a bang causing the on deactivate of the mouse. Beware that after this you will not be able to use the on undo event.

      Hope this helps.

      • #1087649

        Rudi,

        I ran tests, checking the value of Me.Dirty as I went along; which is how I came to my conclusion. So I am confident what I said is correct.

        • #1087651

          Hi Mark,

          I am not questioning or doubting your expertise in Access and what you posted. I am simple getting up to my usual no good and trying to have some humour at no-ones expense. The lounge needs a clown or two (since computers are such a serious business) and I seem to have unwittingly accepted the challenge. nuts

          PS: I was initally amused at the title of this thread and was naturally drawn to say something lighthearted about it. grin (All in innocent fun.

          Cheers

          • #1087682

            Rudi,

            That ‘s OK. Often my attempts at humor miss the mark also (tough crowd). But as I always say: No blood, no foul!

            • #1087684

              If your attempts at humor miss the Mark, you can’t expect anyone else to understand them! evilgrin

            • #1087698

              Groan! (which is the best possible response to a pun!)

    Viewing 1 reply thread
    Reply To: Sometimes OnDirty Event won’t fire (All)

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

    Your information: