By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Changing the error message on delete key

100+
P: 176
Hi, in my form I can't delete certain records because of referential integrity. Therefore, when I press the delete key on those records which have child fields I get an ms-access error (No3300) message "The records can't be deleted or changed because..." . Is there any way to customize this message?

Thanks a lot for your attention.
Good day.
Jan 11 '07 #1
Share this Question
Share on Google+
11 Replies


nico5038
Expert 2.5K+
P: 3,072
Thta's hard as it's a jet-message.
Personally I try to prevent this by blocking the records that can't be deleted.
When you check in the OnCurrent event of the (sub)form or a related record is present, then disable the [Del] button on your form, else enable it.
That way the user has visual feedback or deletion is an option..
Nic;o)
Jan 11 '07 #2

MSeda
Expert 100+
P: 159
You didn't exactly specify how your form works but you should be able to enter some code in the forms beforedeleteconfim event to test for related records before the delete occurs and insert your own msgbox. This will cancel the delete before accesses error message.

If Not IsNull(DLookup("[Qu Quoted by]", "[Quote Table]", "[QU Quoted by] = '" & Me.EmpCode & "'")) Then

MsgBox "Can Not Delete Record Because Associated Records Exist."
Cancel = True

End If

you can add addition dlookups to test for records in other tables by use AND in the one if Statement or use nested ifs.
Jan 11 '07 #3

100+
P: 176
Dear Nico and Mseda. Both your advices are helpful. I'll go for Mseda's one as it takes less computer power as the user very seldom has to delete a record.
Jan 11 '07 #4

ADezii
Expert 5K+
P: 8,638
Hi, in my form I can't delete certain records because of referential integrity. Therefore, when I press the delete key on those records which have child fields I get an ms-access error (No3300) message "The records can't be deleted or changed because..." . Is there any way to customize this message?

Thanks a lot for your attention.
Good day.
In the Form's Error() Event, you can set the Response Parameter = acDataErrContinue then your own Custom Error Message. Your Error Message will be displayed while the built in Access Error Message will not.
Jan 12 '07 #5

100+
P: 176
In the Form's Error() Event, you can set the Response Parameter = acDataErrContinue then your own Custom Error Message. Your Error Message will be displayed while the built in Access Error Message will not.
Thanks, it sounds the most convinient way,
please tell me how exactly do I set the Response Parameter

Michael.
Jan 25 '07 #6

ADezii
Expert 5K+
P: 8,638
Hi, in my form I can't delete certain records because of referential integrity. Therefore, when I press the delete key on those records which have child fields I get an ms-access error (No3300) message "The records can't be deleted or changed because..." . Is there any way to customize this message?

Thanks a lot for your attention.
Good day.
The correct way to do exactly what you are requesting is by entering code in the Form's Error() Event which can replace the Standard Access Error Message with one that you can customize:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.     If DataErr = 3200 Then      'Can't Delete because of RI
  3.        MsgBox "You cannot DELETE this Record because of Child Records",   vbExclamation, "Delere Notification"
  4.        Response = acDataErrContionue
  5.     End If
  6. End Sub
Jan 25 '07 #7

missinglinq
Expert 2.5K+
P: 3,532
Should Response = acDataErrContionue
Be Response = acDataErrContinue
Jan 25 '07 #8

ADezii
Expert 5K+
P: 8,638
Should Response = acDataErrContionue
Be Response = acDataErrContinue
By all means it should! Thanks for pointing out the typo.
Jan 25 '07 #9

missinglinq
Expert 2.5K+
P: 3,532
You'd hate to get an error message on an error message!
Jan 25 '07 #10

ADezii
Expert 5K+
P: 8,638
You'd hate to get an error message on an error message!
Would that be an Error Error Message?
Jan 25 '07 #11

nico5038
Expert 2.5K+
P: 3,072
I hate error messages in general. Thus my proposal to prevent them on forehand <LOL>

Nic;o)
Jan 25 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.