?
Solved

Transactions with .Recordset Clone?

Posted on 2000-03-29
4
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

771 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