1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MS ACCESS】VBAでDAOを用いたトランザクション

Posted at

メモとして残します。

■やり方

Sub InitLocalData()
On Error GoTo ErrorHandler
    Dim wrkCurrent As DAO.Workspace
    Set wrkCurrent = DBEngine.Workspaces(0)
    wrkCurrent.BeginTrans'ビギン
    'トランザクション処理(dao関係)

    wrkCurrent.CommitTrans'コミット
    Exit Sub
ErrorHandler:
   wrkCurrent.Rollback'ロールバック
End Sub

■さいごに

あくまでDAO関係のトランザクションなのでADOはおそらく別のはずです。
あと、風のうわさで聞いたのですが、トランザクション処理にMysqlやsqlserverといった特殊なリンクテーブルを参照する場合は、うまくいかないことがあるみたいなので、この方法でのトランザクションはやめたほうが良いでしょう。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?