473,490 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Create 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.SetWarnings False
DoCmd.RunSQL ("UPDATE Products " & "SET
Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] " & "WHERE
(([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]));")
DoCmd.SetWarnings 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 "dbFailOnError" after my UPDATE code?
Nov 13 '05 #1
4 1340
On 29 Aug 2004 08:16:54 -0700, rc*********@yahoo.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.SetWarnings False
DoCmd.RunSQL ("UPDATE Products " & "SET
Products.ContainerNumberProductsTable =
[Forms]![ContainerAssociationForm]![GETContainerNumber] " & "WHERE
(([Products.PalletNumberProductsTable]=[Forms]![ContainerAssociationForm]![PalletNumberContainerFormComboBox]));")
DoCmd.SetWarnings 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 "dbFailOnError" after my UPDATE code?


Nov 13 '05 #2
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.

--
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********@bway.net.invalid> wrote:

I've never seen that documented. Where did you find that?
' air code
on error resume next
CurrentDb.Execute "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.com:
On Mon, 30 Aug 2004 18:41:18 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:
Tom van Stiphout <no*************@cox.net> wrote in
news:i5********************************@4ax.co m:
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.Execute "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
8942
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...
6
2566
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...
29
5768
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...
1
5741
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...
9
2030
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...
11
12966
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...
2
2353
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,...
3
3095
by: BLUE | last post by:
Only SQL Server 2005 or also DB2, Oracle and MySQL? Thanks, Luigi.
4
2003
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....
0
7142
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,...
1
6847
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...
0
7352
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
5445
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,...
1
4875
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...
0
4565
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
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 ...
0
272
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...

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.