code problem

G

Guest

hi,
I have the following function which is used for determine which value should
be displayed for each employee. The problem is when there is no value, an
error massage appears. I want some body complete the function if there is no
value the txt26 will be red colored.

If Me.Category = "S1" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S2" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S3" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S4" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S5" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S6" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S7" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S8" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S9" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "S10" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "s11" Then
Me.txt26.BackColor = vbRed
End If
End Sub
 
S

Stefan Hoffmann

hi Jon,
I have the following function which is used for determine which value should
be displayed for each employee. The problem is when there is no value, an
error massage appears. I want some body complete the function if there is no
value the txt26 will be red colored.

If Me.Category = "S1" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S2" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S3" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S4" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S5" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S6" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S7" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S8" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S9" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "S10" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "s11" Then
Me.txt26.BackColor = vbRed
End If
End Sub

Select Case Nz(Me![Category], "XXX")
Case Is = "S1", "S2", "S3", "S4"
txt22.BackColor = vbGreen
Case Is = "S5", "S6", "S7", "S8"
txt24.BackColor = vbYellow
Case Is = "S9", "S10", "S11", "XXX"
txt26.BackColor = vbRed
Case Else
MsgBox "No colorizer defined."
End Select


mfG
--> stefan <--
 
G

Guest

Hi,
Thanks a lot, but the problem still running
It shows that there is an error in the following line
Select Case Nz(Me![Category], "XXX")



Stefan Hoffmann said:
hi Jon,
I have the following function which is used for determine which value should
be displayed for each employee. The problem is when there is no value, an
error massage appears. I want some body complete the function if there is no
value the txt26 will be red colored.

If Me.Category = "S1" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S2" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S3" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S4" Then
Me.txt22.BackColor = vbGreen
End If
If Me.Category = "S5" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S6" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S7" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S8" Then
Me.txt24.BackColor = vbYellow
End If
If Me.Category = "S9" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "S10" Then
Me.txt26.BackColor = vbRed
End If
If Me.Category = "s11" Then
Me.txt26.BackColor = vbRed
End If
End Sub

Select Case Nz(Me![Category], "XXX")
Case Is = "S1", "S2", "S3", "S4"
txt22.BackColor = vbGreen
Case Is = "S5", "S6", "S7", "S8"
txt24.BackColor = vbYellow
Case Is = "S9", "S10", "S11", "XXX"
txt26.BackColor = vbRed
Case Else
MsgBox "No colorizer defined."
End Select


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Jon,
Thanks a lot, but the problem still running
It shows that there is an error in the following line
Select Case Nz(Me![Category], "XXX")
What kind of error message do you get exactly?


mfG
--> stefan <--
 
G

Guest

Run-time erro’-2147352567(80020009)
You entered an expression that has no value
This is what I get

thanks!!

Stefan Hoffmann said:
hi Jon,
Thanks a lot, but the problem still running
It shows that there is an error in the following line
Select Case Nz(Me![Category], "XXX")
What kind of error message do you get exactly?


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Jon,
Run-time erro’-2147352567(80020009)
You entered an expression that has no value
This is what I get
Select Case Nz(Me![Category], "XXX")
What kind of error message do you get exactly?
How is [Category] defined? It is a field or a control? Is it an
expression in the data source?


mfG
--> stefan <--
 
G

Guest

it is a field

Stefan Hoffmann said:
hi Jon,
Run-time erro’-2147352567(80020009)
You entered an expression that has no value
This is what I get
Select Case Nz(Me![Category], "XXX")
What kind of error message do you get exactly?
How is [Category] defined? It is a field or a control? Is it an
expression in the data source?


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi Jon,
it is a field
Sounds weird. I don't think it is caused by the code. Try the following:

Dim Test As String

Test = Nz(Me![Category], "XXX")

Select Case Test
Case....
End Select


mfG
--> stefan <--
 
G

Guest

I think that I found the problem, it was the field name it was wrong, but
know there is a problem which is all colors appears and there is no category



Stefan Hoffmann said:
hi Jon,
it is a field
Sounds weird. I don't think it is caused by the code. Try the following:

Dim Test As String

Test = Nz(Me![Category], "XXX")

Select Case Test
Case....
End Select


mfG
--> stefan <--
 

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