Solved

Transaction Processing

Posted on 1998-12-15
1
131 Views
Last Modified: 2010-05-03
Can I have a trasaction that spans multiple forms?  To do this, do I have to define Workspace and define and open the DB in a global module shared by all forms in my application?
0
Comment
Question by:baileys
[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
1 Comment
 
LVL 3

Accepted Solution

by:
vbWhiz earned 100 total points
ID: 1450368
In a word, Yes Yes.

Unless you are using bound forms. I havn't ever used bound forms in VB so if you are that may make things a little more difficult.

If, however, you save information to the database using code then it is really quite simple to wrap data alterations in a transaction. The more difficult part is structuring your application in a way that makes it easy to understand what is going on or that seamlessly uses transactions behind the scenes to insure the data is being modified all at once.


This is some psuedo code (you probably don't want buttons to begin, commit, and cancel the transaction. This is just to illustrate how to use transactions in a form-based application using a public workspace variable.)


'[Code in the declarations section of a module]

Public WS as workspace
Public DB as database
Public TransactionInProcess AS Boolean

Public Sub Connect()

Set WS = DBEngine.CreateWorkspace("","Admin","")
Set DB= WS.OpenDatabase("C:\MyDB.mdb")

End Sub




'[Code in the header form]

Private Sub cmdBeginTrans_Click()

  IF TransactionInProcess Then Exit Sub

  WS.BeginTrans

End Sub

Private Sub CmdSave_Click()

'Save the info here using a recordset created from the public DB

End Sub


Private Sub cmdCommitTrans_Click()

  IF Not TransactionInProcess Then Exit Sub

  WS.CommitTrans

End Sub

Private Sub cmdCancelTrans_Click()

  IF Not TransactionInProcess Then Exit Sub

  WS.Rollback

End Sub



'[Code on a detail form]

Private Sub CmdSave_Click()

'Save the info using another recordset based on the public DB

End Sub


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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