What is wrong with this?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Private Sub Form_Close()


If Me.Dirty Then
DoCmd.RunMacro (macEmailReferral)
DoCmd.Close acForm, "frmDiscAdd"
Else
DoCmd.Close acForm, "frmDiscAdd"

End If



End Sub

I am trying to have the form close in a different way if it is dirty. What
am I doing wrong?
 
Too late.

If the form is dirty, Access fires this sequence of events:
Form_BeforeUpdate
Form_AfterUpdate
Form_Unload
Form_Close

As you can see, it is no longer dirty by the time the Close event fires.
 
What is the error you get --- or what result do you see???

By the way, you can use a shortcut when closing the form from within the
form by using:

DoCmd.Close acForm, Me.Name

Bob.
 
Thanks. That makes sense. It was driving me CRAZY!!!!!
--
Thanks As Always
Rip


Allen Browne said:
Too late.

If the form is dirty, Access fires this sequence of events:
Form_BeforeUpdate
Form_AfterUpdate
Form_Unload
Form_Close

As you can see, it is no longer dirty by the time the Close event fires.
 
Thanks Bob. I was getting a compile error and had to debug. I moved the
event to the BeforeUpdate and it works fine. Thanks to Allen for the order
tip. Thank you for the acform, me.<formName> tip.

I am a self taught, and not very well, Access dude. I don't do code well at
all.
--
Thanks As Always
Rip


Bob Howard said:
What is the error you get --- or what result do you see???

By the way, you can use a shortcut when closing the form from within the
form by using:

DoCmd.Close acForm, Me.Name

Bob.
 
I also read Allen's reponse so we both learning something. That's the way I
learned Access, although I've got a very long way to go!


Ripper said:
Thanks Bob. I was getting a compile error and had to debug. I moved the
event to the BeforeUpdate and it works fine. Thanks to Allen for the order
tip. Thank you for the acform, me.<formName> tip.

I am a self taught, and not very well, Access dude. I don't do code well at
all.
 
Back
Top