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
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