A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Pull report values in VBA



 
 
Thread Tools Display Modes
  #1  
Old March 25th, 2010, 09:16 PM posted to microsoft.public.access.reports
cunger28
external usenet poster
 
Posts: 29
Default 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
  #2  
Old March 26th, 2010, 03:51 AM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Pull report values in VBA

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.