|
Written by Garry Robinson from GR-FX Pty Limited Sometimes it is important to ensure that multiple queries have all run correctly together before you save the results. Microsoft Access allows you to do this through the use of transactions. Following is some example code that runs a number of different action queries using the transaction method Private Sub cmdPostBatch_Click()On Error GoTo errorTransaction 'Set up all the declarations and begin the transactions Dim myWrk As
DAO.Workspace, myDbs As DAO.DATABASE, sqlStr As
String sqlStr = "UPDATE PaymentPeriods SET
PaymentPeriods.runStatus = 'P' WHERE (((PaymentPeriods.paymentRunId)= " &
[Forms]![FX_Payments]![paymentRunId] & "))" ' Now all the action queries are
commited together ' Something happened so all the
queries are not committed end sub
querydef execute and look for the DB_FAILONERROR option to the execute method.
Try out our popular Access shareware Graf-FX
|
|
Links >>> Home | Search | Workbench | Orders | Newsletter | Access Security | Access professionals |