I have a conditional formatting rule that enables some fields depending on choices earlier. The fields are disabled by default. Once these fields are enabled, they also require input. However since they are conditional I cannot make them required on the database level.
What I've tried is to check in the submit handler if the control is enabled and not empty.
Public Sub SaveButton_Click()
For Each ctl In Me.Controls
If (ctl.Tag = "ConditinallyRequiredField") Then
If (ctl.Enabled = True) Then
Debug.Print "This is never reached"
' Check for empty values.
If (Len(ctl.Value & vbNullString) = 0) Then
MsgBox "One or more required fields are missing input values."
GoTo stopSubmit
End If
End If
End If
Next ctl
... Do submit
End Sub
But ctl.Enabled
is always false, no matter at what point in time I check it. So it looks like the conditional formatting overrides it without affecting the actual property.
So since ctl.Enabled
apparently always remains false, I would like to check if there is a conditional formatting rule active for the given control (there is only one). But so far I have not found to do so. Can it be done?