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

    Sometimes OnDirty Event won't fire (All)

    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!".
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: Sometimes OnDirty Event won't fire (All)

    Thanks! <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sometimes OnDirty Event won't fire (All)

    Since this post seems to be at the end of its thread, could I offer my <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15> 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.
    Regards,
    Rudi

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

    Re: Sometimes OnDirty Event won't fire (All)

    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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sometimes OnDirty Event won't fire (All)

    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. <img src=/S/nuts.gif border=0 alt=nuts width=15 height=15>

    PS: I was initally amused at the title of this thread and was naturally drawn to say something lighthearted about it. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> (All in <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20> fun.

    Cheers
    Regards,
    Rudi

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

    Re: Sometimes OnDirty Event won't fire (All)

    Rudi,

    That 's OK. Often my attempts at humor miss the mark also (tough crowd). But as I always say: No blood, no foul!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

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

    Re: Sometimes OnDirty Event won't fire (All)

    If your attempts at humor miss the Mark, you can't expect anyone else to understand them! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

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

    Re: Sometimes OnDirty Event won't fire (All)

    Groan! (which is the best possible response to a pun!)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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