Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Dirty is True but no changes have been made to form

Status
Not open for further replies.

projecttoday

Programmer
Feb 28, 2004
208
US
I have a form with a button on it. This is a close form button. When clicked it hits

If Me.Dirty Then

followed by a prompt that asks the user if he wants to save the record. The problem is Me.Dirty is coming up true even when no entries have been made on the form. I have used this same code in other databases and it worked. Any ideas?

Robert
 
Probably you have code in the form that dirties the record, for instance some assigning of value to controls in the forms on current event or something similar.

Roy-Vidar
 
How about trapping the code with a break.


Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Use the event before update or after update!
 
Roy-Vidar I think you are right. I have a field in the table where I want to put a date stamp whenever a record is changed:


Private Sub Form_Current()
[editdate] = Date
End Sub

I tried

Private Sub Form_Current()
I Me.Dirty then
[editdate] = Date
End If
End Sub

and I got an error message. Any ideas?
 
Use the before update event of the form. That triggers when a save is performed.

Roy-Vidar
 
For the automatic change timestamp:
Private Sub Form_[!]BeforeUpdate[/!]()
Me![editdate] = Now
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Whoa! You guys are fast. I thought of that right after I clicked submit. It's working now. Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top