Issue with the After Update Event on check box when false

Snowflake68

Registered User.
Local time
Today, 22:13
Joined
May 28, 2014
Messages
464
I have a check box with the code below on the After Update event however not all of the code runs when the check box = False (unticked) I have placed message boxes to test to see which parts of the code are running and the odd thing is that the Else part does appear to run but it doesnt fire the message up nor does it continue with the next part of the code to check values A.

Code:
Private Sub chkShipTo_AfterUpdate()
                 
    If chkShipTo = vbTrue Then
        txtShipToDetails.Visible = True
        cboShipTo = Null
        cboShipTo.Enabled = False
        txtShipToDetails.Enabled = True
        txtShipToDetails.SetFocus
        MsgBox "TRUE"
    Else
        txtShipToDetails.Visible = False
        cboShipTo.Enabled = True
        cboShipTo.Value = cboBillTo.Value
        txtShipToDetails = Null
        cboShipTo.SetFocus
'Codes appears to run up to this point as the controls are enabled and hidden etc but but the message box doesnt pop up and doesn't continue with checking the next part of the code (which I have omitted for simplicity but just put a message box to check where things have go to)

Also I have a text box called cboShipTo that I need to requery before I check the Values but that doesnt update unless I requery the actual check box and then this only updates when the check box is True. I am very baffled with this one. :banghead:
        
        MsgBox "FALSE"
    End If

    MsgBox "Continue"

    chkShipTo.Requery
    cboShipTo.Requery
    
End Sub
 
Walk through the code with F8 ?
That is what I do when my code does not behave the way I thought it would.
That way you can also inspect values in controls & variables.
 
Walk through the code with F8 ?
That is what I do when my code does not behave the way I thought it would.
That way you can also inspect values in controls & variables.

thanks for the idea which I have given a go but still no luck.

I tried to setfocus immediately after the update (being the first line of the code before the If statement and also within the else part of the code although that was already setting the focus elsewhere).

It must know that the check box is false otherwise it wouldnt hide and and enabled the other controls (as per the code) so why does it stop?

This one has really got me stumped:confused:
 
thanks for the idea which I have given a go but still no luck.

I tried to setfocus immediately after the update (being the first line of the code before the If statement and also within the else part of the code although that was already setting the focus elsewhere).

It must know that the check box is false otherwise it wouldnt hide and and enabled the other controls (as per the code) so why does it stop?

This one has really got me stumped:confused:

Could have sworn you said to try moving the focus?

How do I use F8 to step through the code?
 
Just realised that I have some code running on one of the controls lost focus event and this is interfering with the after update event on the check box. If I comment out the lost focus code then all is working perfect.

Just got to sort the lost focus code out :)

Thanks for helping :)
 

Users who are viewing this thread

Back
Top Bottom