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!

Dirty event throwing up errors

Status
Not open for further replies.

benwah

Technical User
Jun 27, 2001
97
GB
Hi all

I am trying to test wether or not a form is 'dirty'. ie wether or not changes have been made. From there i ask the user if they would like the changes to be saved.

Below is the code i use but I keep getting an error message "You entered an expression that has an invalid referance to the property dirty. The property may not exist or apply to the object you specified."

I have a feeling that because i am using the code behind a button it wont work but if i have the code in the unload event of a form it will.

Does anyone have any ideas as to why?


Private Sub btnClose_Click()
On Error GoTo errortrap

If Me.Dirty = True Then
If MsgBox("Changes have been made since the last save. Would you like to save these changes before continuing?", vbYesNo, "Save Current Record") = vbYes Then
If IsNull(Me.txtSerialNumber) Or Me.txtSerialNumber = "" Then
MsgBox "Invalid Serial Number - Cannot continue.", vbOKOnly, "Save Error!"
Exit Sub
Else
DirtyNewItemForm
End If
End If
End If

DoCmd.Close acForm, "frmAddNewItem"


errorexit:
Exit Sub

errortrap:
MsgBox Err.Description
Resume errorexit
End Sub
 
Is this form bound to a record set or a table or is it an unbound form? Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top