Solved

Transactions with .Recordset Clone?

Posted on 2000-03-29
4
357 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

828 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