473,883 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete message - Can is selectively be turned off?

Thanks for take time to read my question!!

I'm using code that will automatically delete rows of data in a field
and of course when you do this Access will prompt you that you are
about to delete x number of rows.

Most of the time I want this message be displayed. Can I use code
that will delete specified rows and not give the message?

Here is the code that I'm currently using:

Dim SQLDelete As String

SQLDelete = "delete from Equipment where EquipID = " & Me.List_Device

DoCmd.RunSQL SQLDelete

Thanks

N. Graves
Nov 13 '05
13 3810
Hi Tony

As you know, either will work, but CurrentDb upates all the collections of
the current database (usually dbEngine(0)(0)) , creates a new object, and
points it to the current database.

dbEngine(0)(0) is therefore better because:
1. It is thousands of times more efficient, since it does not have to flush
the collections, and the object already exists.

2. It survives more than one line, e.g. the next line might be:
MsgBox dbEngine(0)(0). RecordsAffected & " deleted."

OTOH, CurrentDb() is better because:
1. It returns correct results if any fields/tables changed recently.

2. The current database might *not* be dbEngine(0)(0). Examples:
- after running a wizard,
- you work with transactions when more than one Database is open (which
happens automatically if you are working with RecordsetClone) .

So, my personal practice is:
- Use CurrentDb() during where tables/fields are being created/modified.
- Use dbEngine(0)(0) for executing queries (other than DDL queries).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tony Toews" <tt****@teluspl anet.net> wrote in message
news:a8******** *************** *********@4ax.c om...
"Allen Browne" <Al*********@Se eSig.Invalid> wrote:
However, you won't know if anything went wrong with the action query. The
following method is better, as it gives a message only if there is a
problem:
dbEngine(0)(0). Execute strSQL, dbFailOnError


Just curious. Why not currentdb.execu te etc?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm

Nov 13 '05 #11

David, Thanks for you information.

I'm getting a compile error for the user-defive type. My inexperience
will not let me continue could you please post this information for
me.

N. Graves
On Mon, 28 Jun 2004 21:25:56 GMT, "David W. Fenton"
<dX********@bwa y.net.invalid> wrote:
"Dave" <e@mail.co.uk > wrote in
news:cb******* ***@sparta.btin ternet.com:
try wrapping the DoCmd like this

Application.Set Option "Confirm Record Changes", False
Application.Set Option "Confirm Document Deletions", False
Application.Set Option "Confirm Action Queries", False
DoCmd.RunSQL SQLDelete
Application.Set Option "Confirm Record Changes", True
Application.Set Option "Confirm Document Deletions", True
Application.Set Option "Confirm Action Queries", True
i use all three lines to turn everything off when distributing
run-times as i dont want uses to have to fiddle around

you will probably find that you dont need all three lines and just

Application.Set Option "Confirm Action Queries", False
DoCmd.RunSQL SQLDelete
Application.Set Option "Confirm Action Queries", True

will do


Why in the world use RunSQL and all those extra switches when in
99.999% of cases, Executing the SQL directly will do the job without
needing to fiddle with warnings and options?

If you want something as simple as DoCmd.RunSQL, try this:

Public Function ExecuteSQL(strS QL As String, _
Optional db As Database) As Boolean
On Error GoTo errHandler

If db Is Nothing Then
Set db = CurrentDB() ' or DBEngine(0)(0)
End If
db.Execute strSQL, dbFailOnError

exitRoutine:
Exit Function

errHandler:
MsgBox "There was an error executing your SQL string: " _
& vbCrLf & vbCrLf & Err.Number & ": " & Err.Description , _
vbExclamation, "Error in mdlDWF.ExecuteS QL()"
Debug.Print "SQL Error: " & strSQL
Resume exitRoutine
End Function

You can then call that as:

ExecuteSQL strSQL

The db argument is useful if you're already caching a global db
variable and want to re-uses it.


Nov 13 '05 #12
N. Graves <ng*****@REMOVE yahoo.com> wrote in
news:a4******** *************** *********@4ax.c om:
I'm getting a compile error for the user-defive type. My
inexperience will not let me continue could you please post this
information for me.


As I wrote to you in email (many people, myself included, consider
it impolite to both post and email; if you do it, you should
indicate that you're doing so in your message. Had you done so I
would have responded only in the newsgroup, not in private email),
you surely are using A2K or later and are falling victim to MS's
ridiculously stupid decision to not use DAO as the default data
access interface.

To fix the problem, while viewing a code module, go to the TOOLS
menu and choose REFERENCES. Search for Microsoft DAO 3.6 Object
Library and check it off. If you're not using ADO, then uncheck it,
as it's not needed (and for many things, Access provides interfaces
to ADO objects like CurrentConnecti on via the Application objet).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #13
David thanks you so much for taking the to answer both the newsgroups
post and my email.

I was not trying to be rude but thought I was probably not the only
person that could learn from you knowledge is why I posted it back in
this group.

This group is so great and you folks that answer these questions are
great. I have used it quite a bit lately and I did not mean to rude.
I apologize and will not do both again.

Thanks again for you responses. They are working perfectly!

N. Graves

On Wed, 07 Jul 2004 01:10:26 GMT, "David W. Fenton"
<dX********@bwa y.net.invalid> wrote:
N. Graves <ng*****@REMOVE yahoo.com> wrote in
news:a4******* *************** **********@4ax. com:
I'm getting a compile error for the user-defive type. My
inexperience will not let me continue could you please post this
information for me.


As I wrote to you in email (many people, myself included, consider
it impolite to both post and email; if you do it, you should
indicate that you're doing so in your message. Had you done so I
would have responded only in the newsgroup, not in private email),
you surely are using A2K or later and are falling victim to MS's
ridiculously stupid decision to not use DAO as the default data
access interface.

To fix the problem, while viewing a code module, go to the TOOLS
menu and choose REFERENCES. Search for Microsoft DAO 3.6 Object
Library and check it off. If you're not using ADO, then uncheck it,
as it's not needed (and for many things, Access provides interfaces
to ADO objects like CurrentConnecti on via the Application objet).


Nov 13 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
3934
by: de Beers | last post by:
mysql_query("DELETE FROM cart WHERE ItemId=$ItemId"); There is the code but the result in my databse is that the ID number changes from, lets say, 77 to 78 with 78's contents being empty. Therefore when I look at the results - the deleted ID77 is gone but now I have ID78 with no content! Does anyone know why and how do I make it stop? MIchael
4
1736
by: Stefan Strasser | last post by:
why is delete an expression and not a statement? (in my draft copy of the standard). I was about to ask the same question about "throw" but found an expression case of throw("return boolvalue ? 5 : throw 5;"). but "delete" neither does exit the scope nor has a return value. any idea? thanks,
2
11328
by: kumar | last post by:
we are trying to delete data from a huge 75 million records table it takes 4hr to prune data delete from Company where recordid in (select top 10000 recordid from recordid_Fed3 where flag = 0) we have a loop that prunes 10000 records at a time in a while loop let me know if there is a better way to acheive this
6
3110
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from the table, but I was not allowed to do that, because "there are records related with those PRODUCTS in other tables (e.g. in table "ORDER_DETAIL").
2
1486
by: Alex | last post by:
I have a datagrid with two additional columns (edit, delete). However the edit and delete handlers in the code behind page are never reached. When I click on the delete or edit button the load page handler gets executed nothing else. What could I do wrong? Here some code: private void InitializeComponent()
6
9777
by: Ivan | last post by:
Hello to all and thanks for answer to my topics. I made one stored procedure that delete one table, but when call/execute the procedure this show SQL0532N A parent row cannot be deleted because the relationship "TXN_TRANSACTION.FK_SCLI " restricts the deletion. Then in the procedure it adds one delete of the foreign keys. This it
1
1307
by: MLH | last post by:
Take the following SQL: DELETE tblPreliminaryVINs.* FROM tblPreliminaryVINs INNER JOIN tblVehicleJobs ON tblPreliminaryVINs.PVIN = tblVehicleJobs.SerialNum; Access 97 consistently disallows me to run queries of this nature. I'm the database owner and the owner of all its objects and have full admin rights to them all. I have absolutely zero problems running
2
2902
by: Andy.I | last post by:
Hi I have a small aplication that stores data in a random access file. I'm able to modify records, and add new records. But how can I delete a certain record and remove it enirely from the file? /A.
3
1625
by: =?Utf-8?B?Qm9iRg==?= | last post by:
I need to move files between folders. I am using VB.Net 2005. First I check the target folder to see if the files exist, and if so, delete them. Then I move the replacements, one at a time using: If File.Exists(strFileName) then File.Delete(strFileName) End If File.Move(strFileOldName, strNewFileName) This works just fine in Windows XP. It works in Windows Vista (Release version) with UAC turned off. With UAC turned on it fails. I...
0
9792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11142
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10416
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3233
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.