How to rollback db Operations

B

bangaram

Hi, i am new to access.i am developing database for Quality dept .First i wil
explain what i suppose to do..i created a Data entry form through which user
can enter the measured data. User can enter measured data for multiple
locations at a time. i am trying to validate the data before stroing in the
database. if any data related to one location is invalid then i will display
an error message to indicate the user. if data is valid for all locations
then only to i have to save it.... but i am not able to do that,,..

can u explain how can i rollback and commit the transactions.... Here is the
code i am trying...let me know where i am doing wrong....


wrkDefault.BeginTrans
While (ind <= locCount)
wrkDefault.BeginTrans
If (Me.Controls("txtVal" & ind) <> "") Then
mValue = Round(Val(Me.Controls("txtVal" & ind)), 3)
dMark = isValidData(Form_frmGenerator.selPartNum, Me.Controls("locLabel" &
ind).Caption, mValue)
If (dMark = 1) Then
Me.Controls("txtVal" & ind).BackColor = RGB(0, 255, 0)
ElseIf (dMark = 2) Then
Me.Controls("txtVal" & ind).BackColor = RGB(255, 255, 0)
Else
Me.Controls("txtVal" & ind).BackColor = RGB(255, 0, 0)
MsgBox "Entered Value is out of Control Limits", vbInformation
sFlag = False
End If
strQuery = "insert into MeasurementData values('" & Form_frmGenerator.
selPartNum & "','" & Me.Controls("locLabel" & ind).Caption & "'," & mValue &
",'" & ReadingDate & "')"
dbObj.Execute strQuery
wrkDefault.CommitTrans
'strQuery = "insert into Measurementdata values('" & Form_frmGenerator.
selPartNum & "','" & cmbLocation.ItemData(cmbLocation.ListIndex) & "','" &
Inspector & "'," & ShiftID.ListIndex + 1 & ",'" & ReadingDate & "'," & sFlag
& ",'" & Check.ItemData(Check.ListIndex) & "'," & mValue & ",'" & Comments &
"')"
'On Error GoTo Err_Insert
' dbObj.Execute (strQuery)
' MsgBox "Record(s) inserted", vbInformation
'Else
' MsgBox "Null values are not inserted", vbCritical
Else
MsgBox "Null values or not accepted", vbCritical
wrkDefault.Rollback
Exit Sub
End If
ind = ind + 1
Wend
wrkDefault.CommitTrans
 
A

Albert D.Kallal

You need to realize that transactions ONLY apply to reocrdets and code you
write.

Transactions do NOT work on forms reocrdsets, and have nothing to do with
ms-access forms...

So, you can create a reocrtdset in code, or execute sql commands in
code..and commit, or roll them back...

However, this does not apply to forms.....

You *can* create a reocrdset in code, and then assign this to a form, but it
gets messy very fast....
 
B

bangaram via AccessMonster.com

Thanks for u r answer. i wil do that...
You need to realize that transactions ONLY apply to reocrdets and code you
write.

Transactions do NOT work on forms reocrdsets, and have nothing to do with
ms-access forms...

So, you can create a reocrtdset in code, or execute sql commands in
code..and commit, or roll them back...

However, this does not apply to forms.....

You *can* create a reocrdset in code, and then assign this to a form, but it
gets messy very fast....
 
Top