Detail_Format in Report

B

Brian

I have a field that is called DBH and I want it to alternate colors but
is says I have a datatype mismatch.. It's a string and I have a total
that I want to be a different color then all the rest but it's not working

select case DBH
Case "6" Or "10" Or "14" Or "18" Or "22" Or "26" Or "30" Or "34" Or "38"
Me.Detail.BackColor = 16777215
Case "8" Or "12" Or "16" Or "20" Or "24" Or "28" Or "32" Or "36" Or "40"
Me.Detail.BackColor = 14211288
Case "Total"
Me.Detail.BackColor = 4194304
end select
 
A

Allen Browne

Try with commas instead of OR.

It might also be easier to convert the string value to a number:

Select Case CLng(Val(Nz([DBH], "0")))
Case 6, 10, 14, ...
 
A

Allen Browne

Just for clarity, Brian, the OR was probably being interpreted as a bitwise
operator, rather than a logical OR.

As in:
2 OR 3
results in 3 (since 3 has both bits on.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Brian said:
worked great did not need to convert it just used the commas... thanx

Allen said:
Try with commas instead of OR.

It might also be easier to convert the string value to a number:

Select Case CLng(Val(Nz([DBH], "0")))
Case 6, 10, 14, ...
 

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