Solved

Transactions with .Recordset Clone?

Posted on 2000-03-29
4
348 Views
Last Modified: 2006-11-17
I can’t get Transactions to work with a recordset created with the Form.RecordsetClone (i.e. updates are made but the .Rollback method does not.  Is it possible to use Transactions on recordsets created with the .RecordsetClone, or is something wrong with my code?
(sample code follows)

Sub ModuleName()
Dim ws As Workspace  
Dim rs As Recordset
Set ws = DBEngine.Workspaces(0)
Set rs = Forms!FormName.RecordsetClone
ws.BeginTrans
While Not rs.EOF
    rs.Edit
    rs!FieldName=SomeValue
    rs.Update
    rs.MoveNext
Wend
If SomeTest = True Then
    ws.CommitTrans
  Else
    ws.Rollback
End if
End Sub
0
Comment
Question by:GJeppson
  • 2
4 Comments
 

Author Comment

by:GJeppson
ID: 2669688
Adjusted points from 100 to 200
0
 
LVL 54

Expert Comment

by:nico5038
ID: 2670336
I'm using Access 2000 and in the helpfile they give a sample for Commit/Rollback, but only for a connection object.

In the sample they create a new adodb.recordset to perform the updates on and conditionally commit or rollback.

Do you have Access 2000 ?
Then check upon the connection object's methods (commit/rollback) for the sample.
0
 
LVL 14

Accepted Solution

by:
mgrattan earned 200 total points
ID: 2725445
Does the form have a subform?  If so, then this behavior is by design and you will need to use more explicit declarations for your recordsets.  See article at http://support.microsoft.com/support/kb/articles/Q131/5/35.asp?LN=EN-US&SD=gn&FR=0
0
 
LVL 54

Expert Comment

by:nico5038
ID: 2727186
Just re-read the question. And are wondering why you are performing a commit/rollback on a RecordsetClone.
It is a copy of a recordset and when you are finished and doesn't want the updates you just "drop-it" and take a new set by specifying set rs = ..recordsetclone again.
When you are concerned that somebody has changed something in the meantime you could use two clone sets: set rs1 to recordsetclone and rs2 = rs1. The instead of a rollback you use rs1 = rs2?!

Basically a commit and rollback is used to secure multiple updates on "real" table(s) and to correct the updates when not every individual update was successfull.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now