Dave Taylor
New member
- Local time
- Today, 12:01
- Joined
- Nov 8, 2007
- Messages
- 4
I have a pulldown field for Status tracking in a Service Records form. I want to interupt the update (hence using Before Update) if the status picked is "Completed" (ID 3) and open a pop up form to confirm that the user has completed certain tasks listed in the pop up. If Yes, the update to Status continues, If No, the update is cancelled and the field reverts to the previous value.
In the Pop up form, clicking Yes results in TempVars!Confirmed = "Yes", and same code for the No button but TempVars!Confirmed = "Yes"
Private Sub cmdYes_Click()
On Error GoTo Err_cmdCloseForm_Click
TempVars!Confirmed = "Yes"
DoCmd.Close
Exit_cmdCloseForm_Click:
Exit Sub
Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click
End Sub
Back on the Service Records form, the code in the Before Update module is shown below and the TempVar is transferred ok as I have it displayed just before I attempt to cancel (or undo) the update to that field. The problem I have is that the field updates even if "Completed" was selected.
I have tried many different methods and can't get the Cancel (or revert to original value) portion to work.
Any help would be appreciated, thanks.
Private Sub ProductServiceStatusID_BeforeUpdate(Cancel As Integer)
If Me.ProductServiceStatusID <> "3" Then
GoTo Exit_ProductServiceStatusID_BeforeUpdate_Click
End If
DoCmd.OpenForm "frm_SrCompletedConfirmationPopUp", WindowMode:=acDialog
MsgBox TempVars!Confirmed
If TempVars!Confirmed = "No" Then
Cancel = True
Undo
Else
Exit Sub
End If
Exit_ProductServiceStatusID_BeforeUpdate_Click:
Exit Sub
End Sub
In the Pop up form, clicking Yes results in TempVars!Confirmed = "Yes", and same code for the No button but TempVars!Confirmed = "Yes"
Private Sub cmdYes_Click()
On Error GoTo Err_cmdCloseForm_Click
TempVars!Confirmed = "Yes"
DoCmd.Close
Exit_cmdCloseForm_Click:
Exit Sub
Err_cmdCloseForm_Click:
MsgBox Err.Description
Resume Exit_cmdCloseForm_Click
End Sub
Back on the Service Records form, the code in the Before Update module is shown below and the TempVar is transferred ok as I have it displayed just before I attempt to cancel (or undo) the update to that field. The problem I have is that the field updates even if "Completed" was selected.
I have tried many different methods and can't get the Cancel (or revert to original value) portion to work.
Any help would be appreciated, thanks.
Private Sub ProductServiceStatusID_BeforeUpdate(Cancel As Integer)
If Me.ProductServiceStatusID <> "3" Then
GoTo Exit_ProductServiceStatusID_BeforeUpdate_Click
End If
DoCmd.OpenForm "frm_SrCompletedConfirmationPopUp", WindowMode:=acDialog
MsgBox TempVars!Confirmed
If TempVars!Confirmed = "No" Then
Cancel = True
Undo
Else
Exit Sub
End If
Exit_ProductServiceStatusID_BeforeUpdate_Click:
Exit Sub
End Sub