473,769 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional formating on a Report

36 New Member
I have a request to highlight any entries in a report that have the same date. The report is sorted by date so the records would be one after the other. I cannot find any events for the report that I would be able to add any code to.

Any input or advice would be appreciated

I would like to figure the code myself as I find I learn better that way, I just can't find an event to put the code into.

My report is based on a saved query, ordered by date

Thanks in advance
Jul 25 '07 #1
2 1554
JConsulting
603 Recognized Expert Contributor
I have a request to highlight any entries in a report that have the same date. The report is sorted by date so the records would be one after the other. I cannot find any events for the report that I would be able to add any code to.

Any input or advice would be appreciated

I would like to figure the code myself as I find I learn better that way, I just can't find an event to put the code into.

My report is based on a saved query, ordered by date

Thanks in advance

That would be the On_Format event for that report section.
J
Jul 26 '07 #2
FNA access
36 New Member
Thanks for pointing me in the right direction. I have played with some code and I got it to work. I am wondering if there is a more efficient way than how I coded it. This gives me the results I want, but it does have to run through the record set several times. As always thank you for the help.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. Dim db As DAO.Database, rst As DAO.Recordset, sSQL As String, DateVar As String
  3. Dim count As Integer, DateStart As Date, DateEnd As Date, Tanker As String
  4.  
  5. Set db = CurrentDb()
  6. count = 0
  7. DateStart = [Forms]![ReportPage]![DateStartTextbox]
  8. DateEnd = [Forms]![ReportPage]![DateEndTextbox]
  9. Tanker = [Forms]![ReportPage]![DataEntryCombobox]
  10.  
  11. DateVar = Me!AlertDate
  12.  
  13. sSQL = "SELECT Alert.AlertDate, AlertBase.TankerBase, AlertBase.FCPC, AlertBase.Status, " & _
  14.     "AlertBase.BirddogID, CombinedValuesAirTanker.AirtankerID, AlertBase.Type, " & _
  15.     "AlertBase.Green, AlertBase.Blue, AlertBase.Yellow, AlertBase.Red, AlertBase.AlertEnd " & _
  16.     "FROM ((Alert INNER JOIN AlertBase ON Alert.AlertID = AlertBase.AlertID) LEFT JOIN " & _
  17.     "AlertBaseTanker ON AlertBase.AlertBaseID = AlertBaseTanker.AlertBaseID) INNER JOIN " & _
  18.     "CombinedValuesAirTanker ON AlertBase.AlertBaseID = CombinedValuesAirTanker.AlertBaseID " & _
  19.     "WHERE (((Alert.AlertDate) Between #" & DateStart & "# And #" & _
  20.     DateEnd & "# ) AND ((AlertBaseTanker.AirTankerID)= '" & _
  21.     Tanker & "' )) ORDER BY Alert.AlertDate;"
  22.  
  23. Set rst = db.OpenRecordset(sSQL, dbOpenSnapshot)
  24.  
  25. rst.MoveFirst
  26.  
  27. Do Until rst.EOF = True or count = 2
  28. If DateVar = rst!AlertDate Then
  29.     count = count + 1
  30. End If
  31.     rst.MoveNext
  32. Loop
  33.  
  34. If count > 1 Then
  35.     Me.Section(acDetail).BackColor = 65535
  36. Else
  37.     Me.Section(acDetail).BackColor = 16777215
  38. End If 
  39.  
  40. End Sub
Jul 26 '07 #3

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

Similar topics

2
357
by: jeffgeorge | last post by:
Trying to add 3 colors to 6 combinations of text possibilities. If this makes sense, the possibilities are: A D (one color for the combo beginning with A) A E B D (One color for the combo beginning with B) B E C D (One color for the combo beginning with C)
2
1645
by: rudy | last post by:
I am trying to highlight the output of a field to display something similar to conditional formating. Would prefer to display the result with a code instead of a colored font or colored background for the sake of using a black and white printer. i.e. if >= 20 then H for highly skilled or >= 15 then S for Skilled Even though the colors work there is only three options to select from under Conditional Formatiting (unless there's a way...
2
2966
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not showing or only part of the data in the field displays (i.e. it will display the last name but not the first name or it will display neither). When the conditional formatting is removed it displays all the data as it should be display so the data...
3
1792
by: Tom | last post by:
Is there any way to use conditional formating to change a control for a field in a continuous form to a textbox, option group or combobox depending on the value of another field on the form? On a continuous form, I need some records to have a textbox, some to have an option group and some to have a combobox in the same field. Thanks, Tom
3
2115
by: Smiley | last post by:
Hi, I know how to do confitional formating in Excel by clicking the wizard. Is this possible in MS Access ? If so, please directly where to look. I found example but nothing as to how to do it. I am very green in this. Please help.
4
8978
by: slinky | last post by:
Thanks in advance... I have a continuous style form with a field for each record called "STATUS". I simply want to have the form load and if the value of the textbox is "Inactive" I want the textbox background to display yellow, else I want it to be just white. Here's my code... but it is not working Private Sub Form_Load() If Me!STATUS = "Inactive" Then Me!STATUS.BackColor = RGB(255, 255, 0) Else
6
6471
by: sphinney | last post by:
I'm trying to change the font color of a textbox on a report to red if the date displayed in the textbox is before today. I'm using the following code to accomplish this: Dim Ctrl1 as Textbox Dim CFO As FormatCondition Dim EXP1str as String EXP1str = "<" & Date Set CFO = Ctrl1.FormatConditions.Add(acExpression, , EXP1str ) CFO.ForeColor = RGB(255, 0, 0)
1
2504
by: Earl Anderson | last post by:
A business colleague and I are collaborating 'long distance' on an applet for work. He is doing the programming and I am doing the business process form design. We had discussed my desire to make all of the textbox fields with the 'focus' become a 'light orange' in backcolor. He is working in A2k3/WinXP and I am working in A2002/WinXP (The users of the applet have A2k3). In our preliminary discussions about this particular enhancement,...
1
1850
by: gtslabs | last post by:
I have a report with 2 subreports The first subreport has 3 fields (Expr1, Field1, Field2) Where Expr1 is a Date I want to highlight the 3 fields if a date is within a range of 2 dates. I was able to test the expression using <>Now() and that worked if I put it in all 3 fields. But how do I do that when I am looking at a range of dates? I do not have a place yet for these 2 dates but was thinking of 2 unbound textboxes on my form.
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
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...
0
9857
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
8867
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...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
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
5294
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...
3
2812
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.