Help with code please

Chimp8471

Registered User.
Local time
Today, 23:14
Joined
Mar 18, 2003
Messages
353
hi can someone please have a look at the following code and tell me whats wrong

i get a message saying "Block if without end if"



Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.Line_LME <= 0.85 Then
Me.Line_LME.ForeColor = vbRed
Me.Line_LME.FontBold = True

Else

If Me.Line_LME >= 0.85 Then
Me.Line_LME.ForeColor = vbBlack
Me.Line_LME.FontBold = False
End If

If Me.Pasteurising <= 0.85 Then
Me.Pasteurising.ForeColor = vbRed
Me.Pasteurising.FontBold = True

Else

If Me.Pasteurising >= 0.85 Then
Me.Pasteurising.ForeColor = vbBlack
Me.Pasteurising.FontBold = False
End If


End Sub



cheers

Andy
 
Code:
If Me.Line_LME <= 0.85 Then
Me.Line_LME.ForeColor = vbRed
Me.Line_LME.FontBold = True

Else

If Me.Line_LME >= 0.85 Then
Me.Line_LME.ForeColor = vbBlack
Me.Line_LME.FontBold = False
End If

If Line_LME is exactly 0.85 it wall always select the first option.

So you are doing two different evaluations for a field.

Code:
If Me.Line_LME <= 0.85 Then
    Me.Line_LME.ForeColor = vbRed
    Me.Line_LME.FontBold = True
Else
    Me.Line_LME.ForeColor = vbBlack
    Me.Line_LME.FontBold = False
End If

Same goes for the second field/control.
 
You'll find it easier to spot these errors if you start to indent your code like I've done above.
 

Users who are viewing this thread

Back
Top Bottom