G
Guest
I need help with error handling. In a form that contains navigation buttons,
if a user were to create a new record and starts to type some data, but
decided to change their mind, Access will give an error message if they try
to back out by closing the form or by trying to move to a different record.
It makes sense because the field(s) for the record are required, so a blank
entry is not acceptable.
What I'd like to do is create a user friendly message, asking the user if
they'd like to delete the blank entry, so if that's what they want, they
don't get a series of errors. Here's what I got so far:
Select Case DataErr
Case 3314
MsgBox "The new record can't be blank. Do you want to delete the
blank _ entry?", vbYesNo, "Blank Record"
If vbYes Then
error_BlankEntry
Else
Exit Sub
End If
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description, vbCritical
End Select
End Sub
--------
Private Sub error_BlankEntry()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End Sub
I get a runtime error 2115 message: The macro or function set to
BeforeUpdate or ValidationRule property for th is field is preventing your
form from saving the data in the field. The first line of the
error_blankentry sub is highlighted. I thought that line just selects the
current record, so it doesn't make sense to me.
Also, I don't seem to find any beforeupdate or validationrule properties
that are causing the problem.
I can't just add a delete button to the form either because it won't work if
the entry is blank.
Please advise!
AA
if a user were to create a new record and starts to type some data, but
decided to change their mind, Access will give an error message if they try
to back out by closing the form or by trying to move to a different record.
It makes sense because the field(s) for the record are required, so a blank
entry is not acceptable.
What I'd like to do is create a user friendly message, asking the user if
they'd like to delete the blank entry, so if that's what they want, they
don't get a series of errors. Here's what I got so far:
Select Case DataErr
Case 3314
MsgBox "The new record can't be blank. Do you want to delete the
blank _ entry?", vbYesNo, "Blank Record"
If vbYes Then
error_BlankEntry
Else
Exit Sub
End If
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description, vbCritical
End Select
End Sub
--------
Private Sub error_BlankEntry()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End Sub
I get a runtime error 2115 message: The macro or function set to
BeforeUpdate or ValidationRule property for th is field is preventing your
form from saving the data in the field. The first line of the
error_blankentry sub is highlighted. I thought that line just selects the
current record, so it doesn't make sense to me.
Also, I don't seem to find any beforeupdate or validationrule properties
that are causing the problem.
I can't just add a delete button to the form either because it won't work if
the entry is blank.
Please advise!
AA