473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Need Asssitance with On Delete Code

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
1 1333
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sam | last post by:
For Example, If I delete two times like the below code, the program will behave differently. is this correct? As C++ FAQ the delete checks where or not f1 has memory. How can the following program...
23
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
15
by: Roy Smith | last post by:
I understand that "delete xp" deletes a scalar object and "delete xp" deletes an array of objects, but what I don't understand is why you need to tell the compiler which you're doing. When you...
7
by: pmatos | last post by:
Hi all, I've been having questions about strings, references, initializations... I've created code (which will not compile due to a reference problem) and I'd like comments on why this won't...
3
by: Randell D. | last post by:
Folks, My internet access is intermitent until I get my own connection inside the next ten days - I say this so that I can thank in advance who ever gives a few seconds to read/answer my...
3
by: Joe | last post by:
Hi, I have written a webpage that allows a user to delete files in asp.net with I am having a small problem. To access this page a user has to login via login.aspx page. After successful...
46
by: Bruce W. Darby | last post by:
This will be my very first VB.Net application and it's pretty simple. But I've got a snag in my syntax somewhere. Was hoping that someone could point me in the right direction. The history: My...
14
by: optimum | last post by:
hi i am kind of new to programming, i have managed to create a simple payroll database in C++, but now i am trying to convert in into C but i am keep getting error, can anyone help me convert this...
1
by: javabeginner123 | last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.