Solved

Transaction Processing

Posted on 1998-12-15
1
132 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

691 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