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 13 3805
You can avoid the message with:
DoCmd.SetWarnin gs False
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
If you need an all-or-nothing result for your action query, you can wrap the
whole thing in a transaction. Example in article:
Archive: Move records to another table
at: http://allenbrowne.com/ser-37.html
--
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.
"N. Graves" <ng*****@REMOVE yahoo.com> wrote in message
news:nq******** *************** *********@4ax.c om... 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
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
hope this helps
Dave
"N. Graves" <ng*****@REMOVE yahoo.com> wrote in message
news:nq******** *************** *********@4ax.c om... 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
Hi "N",
Try using the Execute Method (DAO), but be sure to include the dbFailOnError
option.
Like this:
....
Dim MyDB As DAO.Database
Set MyDB = CurrentDB
Dim SQLDelete As String
SQLDelete = "delete from Equipment where EquipID = " & Me.List_Device
MyDB.Execute SQLDelete, dbFailOnError
Set MyDB = Nothing
....
--
HTH,
Don
=============== ==============
Use My*****@Telus.N et for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)
I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.
Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop
=============== =============== ==
"N. Graves" <ng*****@REMOVE yahoo.com> wrote in message
news:nq******** *************** *********@4ax.c om... 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
Thanks so much for your good and quick response...
p.s. N = Norris ;-)
Thanks
On Mon, 28 Jun 2004 15:43:13 GMT, "Don Leverton"
<le************ ****@telusplane t.net> wrote: Hi "N",
Try using the Execute Method (DAO), but be sure to include the dbFailOnError option. Like this:
... Dim MyDB As DAO.Database Set MyDB = CurrentDB
Dim SQLDelete As String SQLDelete = "delete from Equipment where EquipID = " & Me.List_Device
MyDB.Execute SQLDelete, dbFailOnError
Set MyDB = Nothing ...
Thanks for you support and quick answer.
I was really pissed to when I found that my database now requires that
I have to include this.
Thanks
N. Graves
On Mon, 28 Jun 2004 15:40:17 +0000 (UTC), "Dave" <e@mail.co.uk > wrote: 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
hope this helps Dave
"N. Graves" <ng*****@REMOVE yahoo.com> wrote in message news:nq******* *************** **********@4ax. com... 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
Wow great follow up to my questions! Thank you Allen.
N. Graves
On Mon, 28 Jun 2004 23:37:44 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote: You can avoid the message with: DoCmd.SetWarnin gs False
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
If you need an all-or-nothing result for your action query, you can wrap the whole thing in a transaction. Example in article: Archive: Move records to another table at: http://allenbrowne.com/ser-37.html
"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
"Dave" <e@mail.co.uk > wrote: 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
I prefer, if DAO, to use Currentdb.Execu te strSQL,dbfailon error command instead of
docmd.runsql. For ADO use CurrentProject. Connection.Exec ute strCommand,
lngRecordsAffec ted, adCmdText
If you're going to use docmd.setwarnin gs make very sure you put the True statement in
any error handling code as well. Otherwise wierd things may happen later on
especially while you are working on the app. For example you will no longer get the
"Do you wish to save your changes" message if you close an object. This may mean
that unwanted changes, deletions or additions will be saved to your MDB.
Also performance can be significantly different between the two methods. One posting
stated currentdb.execu te took two seconds while docmd.runsql took eight seconds. As
always YMMV.
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
"Dave" <e@mail.co.uk > wrote in
news:cb******** **@sparta.btint ernet.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.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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,
|
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
|
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").
|
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()
| |
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
|
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
|
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.
|
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...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |