transaction processing in MDB?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to process transactions in a batch, so that I can move records from
one pair of tables to another, in safety. I thought I could enclose the
relevant code in a BeginTrans ... CommitTrans loop, but now I think that is
only for ADPs.

How should I be doing this?

Regards,
Allen
 
You can use the batch methods. Begin/CommitTrans etc. are members of the
Workspace class in DAO - see Help for guidance.

Cheers.

BW
 
hi Allen,

Allen_N said:
I want to process transactions in a batch, so that I can move records from
one pair of tables to another, in safety. I thought I could enclose the
relevant code in a BeginTrans ... CommitTrans loop, but now I think that is
only for ADPs.
No, it also applies for .mdbs. Use DBEngine.Workspaces(0).

(From a german microsoft kb article)

---
Sub ChangeTitle()

Dim strName As String, strMessage As String, strPrompt As String
Dim wspDefault As Workspace, dbsNorthwind As Database
Dim rstEmployees As Recordset
strPrompt = "Position in 'Verkaufsrepräsentant' ändern?"
Set wspDefault = DBEngine.Workspaces(0) ' Standard-Arbeitsbereich
' bestimmen.
' Aktuelle Datenbank bestimmen.
Set dbsNorthwind =
wspDefault.OpenDatabase("c:\access\beispiel\NORDWIND.MDB")
' Tabelle öffnen.
Set rstEmployees = dbsNorthwind.OpenRecordset("Personal", dbOpenTable)

wspDefault.BeginTrans ' Transaktion einleiten.

rstEmployees.MoveFirst
Do Until rstEmployees.EOF
If rstEmployees![Position] = "Vertriebsmitarbeiter" Then
strName = rstEmployees![Nachname] & _
", " & rstEmployees![Vorname]
strMessage = "Angestellter: " & strName & Chr(10) & Chr(10)
If MsgBox(strMessage & strPrompt, vbQuestion + vbYesNo, _
"Berufsbezeichnung ändern") = vbYes Then
rstEmployees.Edit ' Änderungen zulassen.
rstEmployees![Position] = "Verkaufsrepräsentant"
rstEmployees.Update ' Änderungen speichern.
End If
End If
rstEmployees.MoveNext ' Zum nächsten Datensatz wechseln.
Loop
If MsgBox("Alle Änderungen speichern?", vbQuestion + vbYesNo, _
"Änderungen speichern") = vbYes Then
wspDefault.CommitTrans ' Änderungen akzeptieren.
Else
wspDefault.Rollback ' Änderungen rückgängig machen.
End If

rstEmployees.Close ' Tabelle schließen.

dbsNorthwind.Close
End Sub


mfG
--> stefan <--
 
Back
Top