Multiple conditions one one textfield?

  • Thread starter Thread starter Arjan
  • Start date Start date
A

Arjan

Hello,

I'm trying to get some conditional format on multiple conditions. this is
the reason i do not use the standard conditional format option. the code
below is what i wrote but it doesn't work, but i don't get any errors either.


******************************************************
Private Sub Form_Load()

If CheckBox.Approved = "no" And TextBox.DueDate < Date And
TextBox.SubmitDate1 = Null Then
TextBox.DueDate.BackColor = "#ff0000"
Else: TextBox.DueDate.BackColor = "#0000ff"

End If
End Sub
******************************************

what Am i doing wrong?

Thanks for helping!
Arjan
 
Try this

If CheckBox.Approved = False And TextBox.DueDate < Date And
Nz(TextBox.SubmitDate1,"") = "" Then
TextBox.DueDate.BackColor = "#ff0000"
Else
TextBox.DueDate.BackColor = "#0000ff"
End If
 
Arjan said:
I'm trying to get some conditional format on multiple conditions. this is
the reason i do not use the standard conditional format option. the code
below is what i wrote but it doesn't work, but i don't get any errors either.


******************************************************
Private Sub Form_Load()

If CheckBox.Approved = "no" And TextBox.DueDate < Date And
TextBox.SubmitDate1 = Null Then
TextBox.DueDate.BackColor = "#ff0000"
Else: TextBox.DueDate.BackColor = "#0000ff"

End If
End Sub
******************************************

What are TextBox and CheckBox? They look like some made up
syntax and make no sense to me. If Approved, DueDate and
SubmitDate1 are the names of controls on the form, then I
will guess that your code should be more like:

Private Sub Form_Load()
If Me.Approved = False And Me.DueDate < Date )
And IsNull(Me.SubmitDate1) Then
Me.DueDate.BackColor = vbRed
Else
Me.DueDate.BackColor = vbBlue
End If
End Sub

Multiple conditions is not a valid reason to avoid
Conditional Formatting. You can use the Expression Is:
option with a condition like:

Not [Approved] And [DueDate]<Date() And [SubmitDate1] Is
Null
 
Back
Top