473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Acc2K - Shading rows in report if criteria is met.

MindBender77
234 100+
Hello All,
I'm not sure if this is possible and have been unsuccessful in my attempts.

Scenerio: I have a report with several fields. If the data in field X = Y then shade the entire row.

I've been attempting to loop through the report using the following in the OnFormat Event:
Expand|Select|Wrap|Line Numbers
  1. For Each ctl In Me.Section(0).Controls
  2.     If ctl.Column(4) = "text string here" Then
  3.         Me.Section(0).BackColor = RGB(255, 255, 255)
  4.     Else
  5.         Me.Section(0).BackColor = RGB(192, 192, 192)
  6.     End If
  7. Next
  8.  
Is what I'm attempting even possible in a report?
Bender
Sep 17 '08 #1
4 1914
Megalog
378 Expert 256MB
I've used Conditional Formatting to do this. I'm not sure if there's a way though VBA to apply the entire row backcolor at once.

So in your case, you might want to try highlighting the cells in the row you want to format, go to Conditional Formatting, and select "Expression is:"
Then put in your condition: [fieldname]="text string here"
Apply the font color/style, or background fill color, and see if it looks good enough for you.
Sep 17 '08 #2
FishVal
2,653 Expert 2GB
Something like the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.     ....
  3.     If X = Y Then Me.Detail.BackColor = ....
  4.     .....
  5. End Sub
  6.  
Sep 17 '08 #3
MindBender77
234 100+
I've used Conditional Formatting to do this. I'm not sure if there's a way though VBA to apply the entire row backcolor at once.
Megalog,
Thank you for your quick reply. However, the problem with using conditional formatting is that there are 11 text strings to search for. CF allows for only 3 which is why was I trying this using VBA.

Bender
Sep 17 '08 #4
MindBender77
234 100+
Thank You All, for your assistance.

With some minor changes I was able to shade the rows in the report. Here is the code in case it can assist others.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel as Integer, FormatCount as integer)
  2. For Each rec In Me.Reports.Controls
  3.     If X = Y Then
  4.         Me.Section(0).BackColor = RGB(192, 192, 192)
  5.     Else
  6.         Me.Section(0).BackColor = RGB(255, 255, 255)
  7.     End If
  8. Next
  9.  
Thanks Again,
Bender
Sep 17 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm,...
1
by: jeffgeorge | last post by:
Using a bit of code to produce alternate line shading in a report. Seems it should work for a form as well but no luck. Does anyone have any ideas what I need to change or if it is even possible...
3
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such...
7
by: Richard Yardley | last post by:
I have a mailing label report and would like to remove the space taken up by rows with no info (move the other rows up). I am a beginner using MS Access 2000 and would appreciate any help. ...
3
by: buck | last post by:
reports/ can we alternate formatting such as "no shading" and then "shading" for multiple records such as a phone directory in Access2000 reports
8
by: | last post by:
hi, i have a form on which a user can choose specific criteria such as dates etc, in order to filter the report that is called from the form. i do this by using the Where section of the...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
2
by: rinmanb70 | last post by:
I have a QBF form/query and a report from the QBF that shows the results of the QBF. I would like to show the criteria on the report that was used in the QBF to get the info on report. I can't...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.