formatting using VB If statement

J

John

I have the following code on the On Format property of one of my Headers on
my report:

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
If ChangePri = True Then
Priority.BackColor = vbGreen
Priority.FontWeight = 800

Else

Priority.BackColor = vbWhite
Priority.FontWeight = 400


If min = True Then
sono.BackColor = vbYellow
sono.FontWeight = 800


Else
sono.BackColor = vbWhite
sono.FontWeight = 400

If missed = True Then
QtyShip.BackColor = vbRed
QtyShip.FontWeight = 800


Else
QtyShip.BackColor = vbWhite
QtyShip.FontWeight = 400

End If
End If
End If

End Sub

The colors are not changing. Is there any other properties that need to be
changed on the report to make this code usable?
 
F

fredg

I have the following code on the On Format property of one of my Headers on
my report:

Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
If ChangePri = True Then
Priority.BackColor = vbGreen
Priority.FontWeight = 800

Else

Priority.BackColor = vbWhite
Priority.FontWeight = 400


If min = True Then
sono.BackColor = vbYellow
sono.FontWeight = 800


Else
sono.BackColor = vbWhite
sono.FontWeight = 400

If missed = True Then
QtyShip.BackColor = vbRed
QtyShip.FontWeight = 800


Else
QtyShip.BackColor = vbWhite
QtyShip.FontWeight = 400

End If
End If
End If

End Sub

The colors are not changing. Is there any other properties that need to be
changed on the report to make this code usable?

Your END If's seem to be in the wrong place... they're all at the end.
Problem is, from your code, I have no idea what belongs where?
Here is an example of the correct syntax.

If CriteriaA = True Then
Do your true stuff here
Elseif CriteriaB = True Then
Do CriteriaB stuff here
If Some other criteria within CriteriaB= True Then
Do more stuff here
End If
Else
Do the Stuff here that does not fit in above
If some more criteria = true Then
More stuff to do
End If
End If

Try again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top