I have a form with a checkbox control on it. When I click on the checkbox, if it is "true" I open a popup form where the user enters specific data into 2 controls. When the user clicks on an OK command button, a value is stored to a public variable and then the popup is hidden.
So...in form A, I have the checkbox. In the before update event, if the checkbox is "true" then the popup form B opens. After the popup form B stores a value to a public variable blnOK then I expect that the next line of code in the form A checkbox before update event should run.
Rather, what is happening is the ENTIRE beforeupdate code runs (even though the popup has opened)...after the before update event ends, THEN the code in the popup OK command button runs, at which point, it is too late.
I use the before update event because if blnOK is false, then I want to undo the checkbox true.
Am I using the wrong event/events to do this? Code for the before update event is pasted below.
Private Sub chkS6MfgSignoff_BeforeUpdate(Cancel As Integer)
If Me.chkS6MfgSignoff = True Then
If IsNull(Me.txtSoftwareVers) Or Me.txtSoftwareVers = "" Then
MsgBox "You must enter the Software version to continue", vbOKOnly + vbExclamation, "Error"
Cancel = True
Me.chkS6MfgSignoff.Undo
Else
DoCmd.OpenForm "frmSelectUser"
'***I would think that the code behind the click event on the OK command button on frmSelectUser would occur here. If I step through the code with breakpoints set, control DOES pass to the frmSelectUser, if I select the module and continue to F8. If I do not select the frmSelectUser module, it continues to step through the beforeupdate event on form A
If blnOK = True Then
Me.txtS6MfgSignoffRecBy = Forms!frmSelectUser.cboUserID.Value
Me.txtS6MfgSignoffDate = Now()
Me.tabCSU5.Visible = True
blnOK = False
DoCmd.Close acForm, "frmSelectUser"
Else
Cancel = True
Me.chkS6MfgSignoff.Undo
End If
End If
Else
Me.txtS6MfgSignoffRecBy = ""
Me.txtS6MfgSignoffDate = ""
Me.chkS6MfgSignoff.Locked = False
Me.tabCSU5.Visible = False
End If
End Sub