Blank entries (1 Viewer)

saintsman

Registered User.
Local time
Today, 03:35
Joined
Oct 12, 2001
Messages
138
I have a form with a field that produces a value based on entries in a sub-form. I have code that produces a different back colour dependent on the value. This works fine provided there is an entry in the sub-form (sometime an entry is not required). If there isn't an entry then the back colour remains the same as the first entry regardless of the value. What am I missing?

Thanks,
Saintsman


Private Sub AvgOfResult_Enter()
If Me.AvgOfResult <= 1 Then
AvgOfResult.BackColor = 12632256
Else
If Me.AvgOfResult > 1 And Me.AvgOfResult <= 7 Then
AvgOfResult.BackColor = 32768
Else
If Me.AvgOfResult > 11 Then
AvgOfResult.BackColor = 255
Else
AvgOfResult.BackColor = 39423
End If
End If
End If
End Sub
 

maxmangion

AWF VIP
Local time
Today, 03:35
Joined
Feb 26, 2003
Messages
2,805
Have you considered using a Case Statement rather than all those If ... Then ... Else statements ?
 

saintsman

Registered User.
Local time
Today, 03:35
Joined
Oct 12, 2001
Messages
138
The answer is no - I don't know what a case statement is!

I have had no training with VBA so I have to adapt what I know, which maybe, is long winded at times. Like a lot of people, if you get something to work once, you tend to stick with it regardless if there is a better way.
 

Users who are viewing this thread

Top Bottom