Show Colour depending on score

waq963

Registered User.
Local time
Today, 10:31
Joined
Jan 27, 2009
Messages
84
Hi, Basically i have a form where a user selects a student and their score appears in a textbox. I want to show a Green box(created in access) if the score textbox is >=400, Amber box if <=300 and Red box if <=200? Thanks.
i used this but doesn't work.
Code:
If (txtTot.Value) >= 400 Then
boxred.Visible = True
boxamber.Visible = False
boxgreen.Visible = False
ElseIf (txtTot.Value) <= 300 Then
boxamber.Visible = True
boxred.Visible = False
boxgreen.Visible = False
ElseIf (txtTot.Value) <= 200 Then
boxgreen.Visible = True
boxred.Visible = False
boxamber.Visible = False
End If
 
Why not just use the CONDITIONAL FORMATTING functionality of Access. It is located on the FORMAT menu (Access 2000-2003). Then you can have one box show the color you want for each record.
 
What do you expect to happen. What is actually happening and why dont you have any code to handle the case where txttot.value is between 301 and 399?
 
Hi, Basically i have a form where a user selects a student and their score appears in a textbox. I want to show a Green box(created in access) if the score textbox is >=400, Amber box if <=300 and Red box if <=200? Thanks.
i used this but doesn't work.
Code:
If (txtTot.Value) >= 400 Then
boxred.Visible = True
boxamber.Visible = False
boxgreen.Visible = False
ElseIf (txtTot.Value) <= 300 Then
boxamber.Visible = True
boxred.Visible = False
boxgreen.Visible = False
ElseIf (txtTot.Value) <= 200 Then
boxgreen.Visible = True
boxred.Visible = False
boxamber.Visible = False
End If

Instead of having 3 coloured boxes, why don't you just have one box and set its colour on the basis of the value? Then you can use a Select Case. This is much simpler.

SHADOW
 
Hi, i have never really used a Case statement, Any help would be appreciated.
 
Hi, i have never really used a Case statement, Any help would be appreciated.

assuming 1 box (calling it colourbox) I would use a case like

Select Case txttot.Value
Case Is < 201
Me.ColourBox.BackColor = 255
Case 201 To 400
Me.ColourBox.BackColor = 38620
Case Is > 400
Me.ColourBox.BackColor = 65280
Case Else
Me.ColourBox.BackColor = 16777215
End Select

but don't forget your error handling and the optimal place to put this event dependent on your form (on current,activate, open, got focus etc)
 
Cheers Mate, works perfectly.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom