MArgente
06-17-2007, 10:54 AM
Hello all,
Can someone enlighten me as to what I'm doing wrong:
Overview:
I have a form where a user enters 2 values. After they enter the 2 values and clicks on a command button, the form's detail becomes visible and several records are displayed (all at the same time, in consecutive rows). I'm using ADO and I'm trying to figure out how to NOT save the changes if the user strays away from the page. This is the code I have so far. I've also tried using transactions (to no avail) but I'd rather not use them.
Private Sub Form_Deactivate()
If rs.State = adStateOpen Then
rs.CancelBatch
rs.Close
End If
End Sub
Private Sub ApproveButton_Click()
On Error GoTo Err_ApproveButton_Click
If Not rs.EOF And Not rs.BOF Then
Response = MsgBox("Are you sure you want to mark the following as approved?", vbYesNo)
If Response = vbYes Then GoTo UpdateApprovals
Else
rs.CancelBatch
End If
Else
MsgBox ("There are no records to be updated.")
End If
Exit Sub
UpdateApprovals:
rs.UpdateBatch
MsgBox ("The approvals were updated.")
Exit Sub
Err_ApproveButton_Click:
MsgBox Err.Description
Exit Sub
End Sub
However, no matter what I do, the items are still updated (which I know is a characterestic of ADO). Any suggestions?
Thank you.
Can someone enlighten me as to what I'm doing wrong:
Overview:
I have a form where a user enters 2 values. After they enter the 2 values and clicks on a command button, the form's detail becomes visible and several records are displayed (all at the same time, in consecutive rows). I'm using ADO and I'm trying to figure out how to NOT save the changes if the user strays away from the page. This is the code I have so far. I've also tried using transactions (to no avail) but I'd rather not use them.
Private Sub Form_Deactivate()
If rs.State = adStateOpen Then
rs.CancelBatch
rs.Close
End If
End Sub
Private Sub ApproveButton_Click()
On Error GoTo Err_ApproveButton_Click
If Not rs.EOF And Not rs.BOF Then
Response = MsgBox("Are you sure you want to mark the following as approved?", vbYesNo)
If Response = vbYes Then GoTo UpdateApprovals
Else
rs.CancelBatch
End If
Else
MsgBox ("There are no records to be updated.")
End If
Exit Sub
UpdateApprovals:
rs.UpdateBatch
MsgBox ("The approvals were updated.")
Exit Sub
Err_ApproveButton_Click:
MsgBox Err.Description
Exit Sub
End Sub
However, no matter what I do, the items are still updated (which I know is a characterestic of ADO). Any suggestions?
Thank you.