[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Transactions with .Recordset Clone?

Posted on 2000-03-29
4
Medium Priority
?
376 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

649 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