473,587 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Acc2K - Shading rows in report if criteria is met.

MindBender77
234 New Member
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 1925
Megalog
378 Recognized Expert Contributor
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 Recognized Expert Specialist
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 New Member
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 New Member
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
7041
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, "frmReportOptions" <== popup form This is the error I get when I try to move to the last page of the report *after* closing the popup: "This expression is typed incorectly, or is too complex to be evaluate...."
1
7351
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 to alternate shade a form??? Private Sub Alternate_Detail_Format(Cancel As Integer, FormatCount As Integer) Const vbLightGrey = 12632256
3
11060
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 as dates) in a text box. This procedure works fine. However, I also need to enter data from a combo box and I cannot get this to work. On my form I've created an unbound combo box named "Name". In the query bound to the report I've entered the...
7
19541
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. Thanks Richard
3
3167
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
13514
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 docmd.openreport as follows DoCmd.OpenReport stDocName, acPreview, , strWhere where strWhere is a string dependant on the choices the user makes in the
6
3664
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 development of reports, it is certainly fine in my book. But for end-users, with little experience or training, it would be nice to have an easy way to handle various selection criteria, perhaps with relatively stock reports. I see easy to use by...
2
4228
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 find how to do this except to show the "hard for users to understand" SQL WHERE statement. Anyone have a better way?
7
3997
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 combination of the combo boxes, some might not be selected etc etc. ie they may want to select the area and ward to show on the report but not the case officer or the property type
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.