My Assistant
![]() ![]() |
|
|
Mar 23 2005, 06:34 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 878 From: California, USA |
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 |
|
|
|
Mar 23 2005, 07:04 PM
Post
#2
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
Since you are not opening your form in acDialog mode the code continues to run even though you have opened a new form. This code will open your form and not continue the rest of your code until the form closes:
DoCmd.OpenForm "frmSelectUser", , , , ,acDialog You may want to consider the After Update event of the check box and not the On Click event... I was unsure if this is what you are doing, so I may be wrong. hth, Jack |
|
|
|
Mar 23 2005, 07:22 PM
Post
#3
|
|
|
UtterAccess Guru Posts: 774 From: Illinois |
What software version are you trying to return? If its Access, you can use code to return that value and therefore you will not need to query the user for it.
|
|
|
|
Mar 24 2005, 10:44 AM
Post
#4
|
|
|
UtterAccess Guru Posts: 878 From: California, USA |
Jack, you are a genius, thank you so much!!
Works like a charm now. I was using the before update event and that event because I want to cancel (unclick) the checkbox if the User does not enter the information properly on the 2nd form. |
|
|
|
Mar 24 2005, 10:47 AM
Post
#5
|
|
|
UtterAccess Guru Posts: 878 From: California, USA |
And it's not asking for the software version of anything on the local machine, it's to show the configuration of a product that we manufacture. The user isn't being queried for the software version; it's a textbox on the same form as the checkbox.
|
|
|
|
Mar 24 2005, 12:02 PM
Post
#6
|
|
|
Retired Moderator Posts: 37,716 From: The San Francisco Bay Area |
You are very welcome and I assume that all is working now as you want. Continued success with your project...
Jack |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 05:17 AM |