Something overriding code

music_al

Registered User.
Local time
Today, 22:50
Joined
Nov 23, 2007
Messages
200
Hi

I have a really simple piece of code that enables or disables 3 controls depending on the state of a checkbox. This was working fine until I applied conditional formatting to these controls. Could it be that the conditional formatting could be re-enabling the controls even when the code above is clearly running (I see it stepping through) and is doing what it should.

As soon as the code is done - the controls get re-enabled. Any ideas why and is it likely to be the conditional formatting that is re-enabling the controls ?

Code:
Sub Check_ASL_State()
    
    If Me.chk_Approved_Special_Leave.Value = 0 Then
        Me.cbo_ASL_Type.Value = Null
        Me.cbo_ASL_Type.Enabled = False
        Me.txt_ASL_Start_Date.Value = Null
        Me.txt_ASL_Start_Date.Enabled = False
        Me.txt_ASL_End_Date.Value = Null
        Me.txt_ASL_End_Date.Enabled = False
    ElseIf Me.chk_Approved_Special_Leave.Value = -1 Then
        Me.cbo_ASL_Type.Enabled = True
        Me.txt_ASL_Start_Date.Enabled = True
        Me.txt_ASL_End_Date.Enabled = True
    End If
End Sub
 
Conditional formatting has the option to enable or disable controls as part of it's operations.

You'll need to move the conditional formatting into code I think, to make it run when you want. Is this a continuous form ? If not you can probably apply your formatting in the on current event.

Also you don't need the elseif condition, your check box can only be one or other state, so simply use an else?
 
Thanks Minty

Its a split form.
 
Hmm. But does the conditional formatting only applies to the main part of the form?

I've avoided split forms like the plague as they don't really play nice, unless you only want to do really basic things. There was a significant thread on here where some much cleverer people than me got really bogged down trying to recreate a "better" split form.

Have you considered using a proper sub form instead?
 
Hi,


Not sure if this link will help at all but maybe take a look anyway?
 

Users who are viewing this thread

Back
Top Bottom