473,614 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

are Transactions necessary with Forms?

RC
I have a form where the user types the shipping container number into
a box and then types the Pallet number into a combo box. The
AfterUpdate event for the combo box runs the following code which
finds every table row that has that pallet number in it and sets the
container number in the next column to match the container number the
user typed into the form. About 15 rows are changed because there are
about 15 boxes in each pallet.

DoCmd.SetWarnin gs False
DoCmd.RunSQL ("UPDATE Products " & "SET
Products.Contai nerNumberProduc tsTable =
[Forms]![ContainerAssoci ationForm]![GETContainerNum ber] " & "WHERE
(([Products.Pallet NumberProductsT able]=[Forms]![ContainerAssoci ationForm]![PalletNumberCon tainerFormCombo Box]));")
DoCmd.SetWarnin gs True

I am using Access 2002. In the database title bar it says "(Access
2000 file format)". In the properties of the form the record source
for the form is the table with all the box and pallet numbers in it.
The database is split and the frontend and backend are both on the
same PC. The database runs only on this PC, it does not run over a
network.

My question is: I this code relatively safe? Do I need to wrap the
procedure in a transaction? I can't tell from all the transaction
messages in the group if I should use a transaction in this case or
not or even whether the form itself handles a type of transaction and
a transaction in code might not work or might mess things up. Should
I add "dbFailOnEr ror" after my UPDATE code?
Nov 13 '05 #1
4 1346
On 29 Aug 2004 08:16:54 -0700, rc*********@yah oo.com (RC) wrote:

On a single action query, transactions are useless. She who uses them
demonstrates she doesn't know how to use them.

If you were to use the Execute method to run your sql statement, yes,
the dbFailOnError flag is a good idea, so you are notified when an
error occurs. This has nothing to do with transactions though.

Transactions only are relevant if more than one action query is run.
The classic example is to run one query to debit an account, followed
by another query to credit another account by the same amount, thus
transferring money from one account to another. You want such code to
be atomic, meaning all is successful, or nothing happened.

-Tom.

I have a form where the user types the shipping container number into
a box and then types the Pallet number into a combo box. The
AfterUpdate event for the combo box runs the following code which
finds every table row that has that pallet number in it and sets the
container number in the next column to match the container number the
user typed into the form. About 15 rows are changed because there are
about 15 boxes in each pallet.

DoCmd.SetWarni ngs False
DoCmd.RunSQL ("UPDATE Products " & "SET
Products.Conta inerNumberProdu ctsTable =
[Forms]![ContainerAssoci ationForm]![GETContainerNum ber] " & "WHERE
(([Products.Pallet NumberProductsT able]=[Forms]![ContainerAssoci ationForm]![PalletNumberCon tainerFormCombo Box]));")
DoCmd.SetWarni ngs True

I am using Access 2002. In the database title bar it says "(Access
2000 file format)". In the properties of the form the record source
for the form is the table with all the box and pallet numbers in it.
The database is split and the frontend and backend are both on the
same PC. The database runs only on this PC, it does not run over a
network.

My question is: I this code relatively safe? Do I need to wrap the
procedure in a transaction? I can't tell from all the transaction
messages in the group if I should use a transaction in this case or
not or even whether the form itself handles a type of transaction and
a transaction in code might not work or might mess things up. Should
I add "dbFailOnEr ror" after my UPDATE code?


Nov 13 '05 #2
Tom van Stiphout <no************ *@cox.net> wrote in
news:i5******** *************** *********@4ax.c om:
On a single action query, transactions are useless. She who uses
them demonstrates she doesn't know how to use them.


Er, that's not true, given that dbFailOnError does not necessarily
roll back the whole update in newer versions of Access.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3
On Mon, 30 Aug 2004 18:41:18 GMT, "David W. Fenton"
<dX********@bwa y.net.invalid> wrote:

I've never seen that documented. Where did you find that?
' air code
on error resume next
CurrentDb.Execu te "myactionquery" , dbFailOnError
if err.number<>0 then
Msgbox "There is a chance some of the action was not rolled back"
end if

-Tom.

Tom van Stiphout <no************ *@cox.net> wrote in
news:i5******* *************** **********@4ax. com:
On a single action query, transactions are useless. She who uses
them demonstrates she doesn't know how to use them.


Er, that's not true, given that dbFailOnError does not necessarily
roll back the whole update in newer versions of Access.


Nov 13 '05 #4
Tom van Stiphout <no************ *@cox.net> wrote in
news:t4******** *************** *********@4ax.c om:
On Mon, 30 Aug 2004 18:41:18 GMT, "David W. Fenton"
<dX********@bw ay.net.invalid> wrote:
Tom van Stiphout <no************ *@cox.net> wrote in
news:i5****** *************** ***********@4ax .com:
On a single action query, transactions are useless. She who uses
them demonstrates she doesn't know how to use them.


Er, that's not true, given that dbFailOnError does not necessarily
roll back the whole update in newer versions of Access.


I've never seen that documented. Where did you find that?
' air code
on error resume next
CurrentDb.Execu te "myactionquery" , dbFailOnError
if err.number<>0 then
Msgbox "There is a chance some of the action was not rolled
back"
end if


Allen Browne brought this to my attention and pointed me to this
article of his:

http://members.iinet.net.au/~allenbrowne/ser-37.html

There it says:

dbFailOnError without a transaction is not enough. In Access 95
and earlier, dbFailOnError rolled the entire operation back, and
the Access 97 help file wrongly claims that is still the case.
(There is a correction in the readme.) FromAccess 97 onwards,
dbFailOnError stops further processing when an error occurs, but
everything up to the point where the error occurred is
committed.

I don't know if Allen can document it or not, but if Allen Browne
says it, I believe it.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5

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

Similar topics

11
8995
by: Alban Hertroys | last post by:
Oh no! It's me and transactions again :) I'm not really sure whether this is a limitation of psycopg or postgresql. When I use multiple cursors in a transaction, the records inserted at the start of the transaction aren't visible to those later on in that transaction (using a different cursor). Attached is a simplified example (the except's are a bit blunt, I know) of what I'm trying to do. In reality, the different cursors are...
6
2582
by: Christopher J. Bottaro | last post by:
Hi, Why is there no support for explicit transactions in the DB API? I mean like transaction() to start the trans and commit() and rollback() would end the trans or something. The reason why I ask is because I wrote a daemon that interacts with a Postgres DB. The value of CURRENT_TIMESTAMP according to Postgres is NOT the actual walltime, but the walltime when the current transaction started. This gets weird when using the Python DB...
29
5794
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using the transaction because I need a way to roll it back if any errors happen during the transaction. Unfortunately all tables affected in the long running transaction are completely locked and nobody else can access any of the affected tables while...
1
5748
by: Nico | last post by:
Hi! I use Windows XP and Access 2002 (XP) SP2 (not SP3) My company has not upgraded to SP3. My problem: -I have a form "F_BOMs" -in this form, i have a sub form called "SF_BOMs" -the sub-form is based on a querry which use 2 tables linked by a primary key. -the form and the sub-form use the parent property of the subform to
9
2050
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could someone please review my before and after code and tell me the proper way to add transactions to my code? Thanks, TD
11
12982
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few days I've been trying to convert some of this code to SQL Server stored procedures, but it seems to lack many of the benefits of C# transactions - a lot of the errors don't seem to be trapped by the SQL error trapping (e.g. if I do an update on a row...
2
2363
by: Adnan | last post by:
Hey Ppl, I'm developing an Online Auction Site using ASP.net and am experiencing a problem with Transactions in ADO.Net. When beginTrasaction() function is invoked from a specific connection, and insertions are made into a table, no other connection can access the table, until the transaction is committed. I've set the Isoloation level to ReadUncommited.
3
3102
by: BLUE | last post by:
Only SQL Server 2005 or also DB2, Oracle and MySQL? Thanks, Luigi.
4
2013
by: steven | last post by:
I have a small database that I have been testing. I get an error about a transaction deadlock. The code is in stored procedures and I added transactions to the sp's but the error happened again. I wrapped the whole sp in just one transaction and I don't have any index on the tables. When I test just by running a program that sends 3 calls at a time it will get a deadlocked transaction as I send 6 or 9 at a time.
0
8182
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8627
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
8579
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...
1
8279
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,...
0
8433
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
4052
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...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2568
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
1
1747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.