Pull report values in VBA

I have a list of fields that I'm pulling in to my report. Basically values 
for Jan - Dec. For each month I would like to conditionally format the back 
color depending on the value each month. Conditonal formatting in Access 07 
only seems to allow 3 conditionals. I need more. I figured why not code it on 
the form open command.  Is this doable?

I thought I could do something along the lines of:
If Me!Jan.Value >= 90 Then 
Me!Jan.BackColor = "#224422"
Else
If Me!Jan.Value < 90 Then 
Me!Jan.BackColor = "#220011"
End If
End If

Whenever I try to preview I get a run time error of 2424. It doesn't like 
the .Value portion of my code.  If it matters at all, the report data is 
being fed from a query and not a static table.

Thanks,

-- 
Chris Unger
Analyst - Tyler, TX
0
Utf
3/25/2010 9:16:01 PM
access.reports 4434 articles. 0 followers. Follow

1 Replies
1558 Views

Similar Articles

[PageSpeed] 16

You should place code in the On Format event of the section containing the 
controls. The color values should be long integers or constants like vbYellow.

-- 
Duane Hookom
Microsoft Access MVP


"cunger28" wrote:

> I have a list of fields that I'm pulling in to my report. Basically values 
> for Jan - Dec. For each month I would like to conditionally format the back 
> color depending on the value each month. Conditonal formatting in Access 07 
> only seems to allow 3 conditionals. I need more. I figured why not code it on 
> the form open command.  Is this doable?
> 
> I thought I could do something along the lines of:
> If Me!Jan.Value >= 90 Then 
> Me!Jan.BackColor = "#224422"
> Else
> If Me!Jan.Value < 90 Then 
> Me!Jan.BackColor = "#220011"
> End If
> End If
> 
> Whenever I try to preview I get a run time error of 2424. It doesn't like 
> the .Value portion of my code.  If it matters at all, the report data is 
> being fed from a query and not a static table.
> 
> Thanks,
> 
> -- 
> Chris Unger
> Analyst - Tyler, TX
0
Utf
3/26/2010 3:51:02 AM
Reply:

Similar Artilces: