P
Patti
Hi!
Almost done with my form -- Access 97. I want to have the
last option be a message box which allows users to select
Yes to save the form or to select No to delete the
record. I've entered the following code from Jim
Allensworth in the Form's BeforeUpdate:
If Me.Dirty Then
If MsgBox ("Save changes?", vbYesNo) = vbNo Then
Me.Undo
Else
Me.Dirty = False
End If
End If
This works fine if No is selected, but I get the following
error if Yes is selected:
Run-time error 2115
The macro or function set to the BeforeUpdate or
Validation Rule property for this field is preventing
Access from saving the data in the field.
I think the problem might be some other code that I
snagged from Allen Browne's website that allows the user
to print the form:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, ,
strWhere
End If
End Sub
I think I can combine these two codes -- Yes equals Save
and Print and No equals Delete, but I'm not sure how. Any
ideas?
Thanks!
Almost done with my form -- Access 97. I want to have the
last option be a message box which allows users to select
Yes to save the form or to select No to delete the
record. I've entered the following code from Jim
Allensworth in the Form's BeforeUpdate:
If Me.Dirty Then
If MsgBox ("Save changes?", vbYesNo) = vbNo Then
Me.Undo
Else
Me.Dirty = False
End If
End If
This works fine if No is selected, but I get the following
error if Yes is selected:
Run-time error 2115
The macro or function set to the BeforeUpdate or
Validation Rule property for this field is preventing
Access from saving the data in the field.
I think the problem might be some other code that I
snagged from Allen Browne's website that allows the user
to print the form:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, ,
strWhere
End If
End Sub
I think I can combine these two codes -- Yes equals Save
and Print and No equals Delete, but I'm not sure how. Any
ideas?
Thanks!