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

Need Asssitance with On Delete Code

P: n/a
Although the code that I'm using for preventing the deletion of
certain keywords does work for an Access 97 DB combo box based on a
separate table, it probably needs to be tweaked because of the strange
post message box errors experienced.

Any assistance to clean up the code below and/or replace it with
something more consistent with the intended results will be
appreciated. Thanks.

On Delete Event Procedure

If Keyword = "Display" Then
MsgBox "This Keyword cannot be deleted."
Cancel = True
End If
End Sub

This seems a little strange, but I have received four different types
of messages following the clicking of okay on the message box, like:
Method 'Do Menu Item' of object 'IDoCmd' failed; the object doesn't
contain the Automation object tblIntro (this is a one check box field
in an unrelated table and even after deleting it and associated code,
it made no difference); database can't find the field "Forms"
referred to in your expression (don't have a field named Forms).
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I prefer not to use the built-in delete commands at all, Dalan, but to write
my own. It's not at all difficult. For example (leaving out some validation
and sanity checks - e.g. we're not at the new record - for brevity) ...

strSQL = "DELETE * FROM SomeTable WHERE SomeField = " & Me!SomeControl
CurrentDb.Execute strSQL, dbFailOnError

That way, you can do your checks before deciding whether to attempt the
deletion at all, rather than allowing the user to attempt the deletion and
then cancelling it.

--
Brendan Reynolds
"Dalan" <ot***@safe-mail.net> wrote in message
news:50*************************@posting.google.co m...
Although the code that I'm using for preventing the deletion of
certain keywords does work for an Access 97 DB combo box based on a
separate table, it probably needs to be tweaked because of the strange
post message box errors experienced.

Any assistance to clean up the code below and/or replace it with
something more consistent with the intended results will be
appreciated. Thanks.

On Delete Event Procedure

If Keyword = "Display" Then
MsgBox "This Keyword cannot be deleted."
Cancel = True
End If
End Sub

This seems a little strange, but I have received four different types
of messages following the clicking of okay on the message box, like:
Method 'Do Menu Item' of object 'IDoCmd' failed; the object doesn't
contain the Automation object tblIntro (this is a one check box field
in an unrelated table and even after deleting it and associated code,
it made no difference); database can't find the field "Forms"
referred to in your expression (don't have a field named Forms).

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.