473,395 Members | 1,495 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,395 software developers and data experts.

Changing Colors of fields on a report

I have access 2k and I have 2 tables. One is a 7X6 table representing
a month with zeroes padding the fields where no day exist. For example
February 2003

0 0 0 0 0 0 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 0
0 0 0 0 0 0 0

Denotes Sunday thru Saturday.

Then I have a separate table that breaks down the month with fields
representing Start Date, End Date, Pay Date, Due Date, and Holiday as
follows

MthNum Month DateNum Year DayNum Day SDate Edate PayDate
Duedate Hol
2 February 1 2003 7 Saturday N N N N Y
N

What I am looking to do is on Dates marked with a "Y" i want to color
and bold--so for start dates I want red and bold, end dates blue and
bold, holidays underlined and so forth. The report is the first table
and I want the number to be formated as stated. Being that the columns
are shown in the detail section of the report and not the individual
fields is ther a way to selectively choose what gets colored and what
doesn't. I have the below code in my detail section

------Start Code----------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim mOn As DAO.Recordset
Dim mOn2 As DAO.Recordset
Dim bOO As Boolean
Dim dNum(10) As Integer
Dim dNum2(10) As Integer
Dim dNum3(10) As Integer
Dim dNum4(10) As Integer
Dim dNum5(10) As Integer
Dim dNum9(15) As Integer
Dim cOunt As Integer
Dim xxx As String
Dim lngRed As Long, lngYellow As Long, lngWhite As Long
Dim lngBlue As Long, lngGreen As Long, lngMagneta As Long

lngRed = RGB(255, 0, 0)
lngblack = RGB(0, 0, 0)
lngYellow = RGB(255, 255, 0)
lngWhite = RGB(255, 255, 255)
lngGreen = RGB(0, 150, 0)
lngBlue = RGB(0, 0, 255)
lngMagneta = RGB(180, 140, 65)

Set mOn = CurrentDb.OpenRecordset("February")
bOO = False
For i = 1 To 7
If Me("day" & i) = 0 Then
Me("day" & i).Visible = False
Else
Me("day" & i).Visible = True
End If
Next i

'then do 8 minus count and fill in with zeroes the do a large if
statement
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(6)) = "Y" Then
dNum(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 9
dNum(cOunt) = 99
Next cOunt
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(7)) = "Y" Then
dNum2(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 9
dNum2(cOunt) = 99
Next cOunt
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(8)) = "Y" Then
dNum3(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 9
dNum3(cOunt) = 99
Next cOunt
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(9)) = "Y" Then
dNum4(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 9
dNum4(cOunt) = 99
Next cOunt
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(10)) = "Y" Then
dNum5(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 9
dNum5(cOunt) = 99
Next cOunt
cOunt = 0
mOn.MoveFirst
Do While Not mOn.EOF
If Trim(mOn.Fields(6)) = "Y" Then
dNum9(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
If Trim(mOn.Fields(7)) = "Y" Then
dNum9(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
If Trim(mOn.Fields(8)) = "Y" Then
dNum9(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
If Trim(mOn.Fields(9)) = "Y" Then
dNum9(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
If Trim(mOn.Fields(10)) = "Y" Then
dNum9(cOunt) = mOn.Fields(2)
cOunt = cOunt + 1
End If
mOn.MoveNext
Loop
'cOunt = 10 - cOunt
For cOunt = cOunt To 14
dNum9(cOunt) = 99
Next cOunt

For i = 1 To 7
If (Me("day" & i) = dNum(0) Or Me("day" & i) = dNum(1) Or Me("day"
& i) = dNum(2) Or Me("day" & i) = dNum(3) Or Me("day" & i) = dNum(4)
Or Me("day" & i) = dNum(5) Or Me("day" & i) = dNum(6) Or Me("day" & i)
= dNum(7) Or Me("day" & i) = dNum(8) Or Me("day" & i) = dNum(9)) Then
Me("day" & i).FontUnderline = True
'Me("day" & i).FontBold = False
'Me("day" & i).ForeColor = lngblack

ElseIf Me("day" & i) = dNum2(0) Or Me("day" & i) = dNum2(1) Or
Me("day" & i) = dNum2(2) Or Me("day" & i) = dNum2(3) Or Me("day" & i)
= dNum2(4) Or Me("day" & i) = dNum2(5) Or Me("day" & i) = dNum2(6) Or
Me("day" & i) = dNum2(7) Or Me("day" & i) = dNum2(8) Or Me("day" & i)
= dNum2(9) Then
Me("day" & i).ForeColor = lngRed
Me("day" & i).FontBold = True
Me("day" & i).FontUnderline = False

ElseIf Me("day" & i) = dNum3(0) Or Me("day" & i) = dNum3(1) Or
Me("day" & i) = dNum3(2) Or Me("day" & i) = dNum3(3) Or Me("day" & i)
= dNum3(4) Or Me("day" & i) = dNum3(5) Or Me("day" & i) = dNum3(6) Or
Me("day" & i) = dNum3(7) Or Me("day" & i) = dNum3(8) Or Me("day" & i)
= dNum3(9) Then
Me("day" & i).ForeColor = lngGreen
Me("day" & i).FontBold = True

ElseIf Me("day" & i) = dNum4(0) Or Me("day" & i) = dNum4(1) Or
Me("day" & i) = dNum4(2) Or Me("day" & i) = dNum4(3) Or Me("day" & i)
= dNum4(4) Or Me("day" & i) = dNum4(5) Or Me("day" & i) = dNum4(6) Or
Me("day" & i) = dNum4(7) Or Me("day" & i) = dNum4(8) Or Me("day" & i)
= dNum4(9) Then
Me("day" & i).ForeColor = lngBlue
Me("day" & i).FontBold = True

ElseIf Me("day" & i) = dNum5(0) Or Me("day" & i) = dNum5(1) Or
Me("day" & i) = dNum5(2) Or Me("day" & i) = dNum5(3) Or Me("day" & i)
= dNum5(4) Or Me("day" & i) = dNum5(5) Or Me("day" & i) = dNum5(6) Or
Me("day" & i) = dNum5(7) Or Me("day" & i) = dNum5(8) Or Me("day" & i)
= dNum5(9) Then
Me("day" & i).ForeColor = lngMagneta
Me("day" & i).FontBold = True

'cc
ElseIf Me("day" & i) <> dNum9(0) And Me("day" & i) <> dNum9(1) And
Me("day" & i) <> dNum9(2) And Me("day" & i) <> dNum9(3) And Me("day" &
i) <> dNum9(4) And Me("day" & i) <> dNum9(5) And Me("day" & i) <>
dNum9(6) And Me("day" & i) <> dNum9(7) And Me("day" & i) <> dNum9(8)
And Me("day" & i) <> dNum9(9) And Me("day" & i) <> dNum9(10) And
Me("day" & i) <> dNum9(11) And Me("day" & i) <> dNum9(12) And Me("day"
& i) <> dNum9(13) And Me("day" & i) <> dNum9(14) Then
Me("day" & i).FontUnderline = False
Me("day" & i).FontBold = False
Me("day" & i).ForeColor = lngblack

'ElseIf Me("day" & i) <> dNum2(0) And Me("day" & i) <> dNum2(1)
And Me("day" & i) <> dNum2(2) And Me("day" & i) <> dNum2(3) And
Me("day" & i) <> dNum2(4) And Me("day" & i) <> dNum2(5) And Me("day" &
i) <> dNum2(6) And Me("day" & i) <> dNum2(7) And Me("day" & i) <>
dNum2(8) And Me("day" & i) <> dNum2(9) Then
'Me("day" & i).ForeColor = lngblack
'Me("day" & i).FontBold = False
'Me("day" & i).FontUnderline = False

'ElseIf Me("day" & i) <> dNum3(0) And Me("day" & i) <> dNum3(1)
And Me("day" & i) <> dNum3(2) And Me("day" & i) <> dNum3(3) And
Me("day" & i) <> dNum3(4) And Me("day" & i) <> dNum3(5) And Me("day" &
i) <> dNum3(6) And Me("day" & i) <> dNum3(7) And Me("day" & i) <>
dNum3(8) And Me("day" & i) <> dNum3(9) Then
'Me("day" & i).ForeColor = lngblack
'Me("day" & i).FontBold = False
'Me("day" & i).FontUnderline = False

'ElseIf Me("day" & i) <> dNum4(0) And Me("day" & i) <> dNum4(1)
And Me("day" & i) <> dNum4(2) And Me("day" & i) <> dNum4(3) And
Me("day" & i) <> dNum4(4) And Me("day" & i) <> dNum4(5) And Me("day" &
i) <> dNum4(6) And Me("day" & i) <> dNum4(7) And Me("day" & i) <>
dNum4(8) And Me("day" & i) <> dNum4(9) Then
'Me("day" & i).ForeColor = lngblack
'Me("day" & i).FontBold = False
'Me("day" & i).FontUnderline = False

'ElseIf Me("day" & i) <> dNum5(0) And Me("day" & i) <> dNum5(1)
And Me("day" & i) <> dNum5(2) And Me("day" & i) <> dNum5(3) And
Me("day" & i) <> dNum5(4) And Me("day" & i) <> dNum5(5) And Me("day" &
i) <> dNum5(6) And Me("day" & i) <> dNum5(7) And Me("day" & i) <>
dNum5(8) And Me("day" & i) <> dNum5(9) Then
'Me("day" & i).ForeColor = lngblack
'Me("day" & i).FontBold = False
'Me("day" & i).FontUnderline = False

End If
Next i
mOn.Close: Set mOn = Nothing
End Sub
-------End Code-------

It seems to work OK for the most part but there seems to be a conflict
in that the 9th and 23rd in column 1 of my first table are sart dates
and should be red abd the 16th is a holiday and should be underlined
and black--but what happens is that it is red and underlined. Is there
a way to specifically choose a row and column number in the report to
access a particular field. Thanks for any help and sorry about my
spaghetti code--i am just learning.

Regards,
Bill Mahoney
The Alcott Group
Nov 12 '05 #1
0 1520

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephan | last post by:
Hi, I'm using Visual Studio 2003 (C#) with the integrated Crystal Report software and have the following question: How can I assign a value (string) to an unbound (string) field in Crystal...
1
by: Rick Measham | last post by:
I can't find this anywhere, so I hope it can be done: Here's what I can do so far: 1. Certain fields have a class 'textfield' while others are 'textfieldreq'. 2. OnSubmit checks all...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
1
by: jhickers | last post by:
In MS 2003 or 2002 can anyone tell me the simplist way to change color of text in a form or report? I want the values of currency fields changed to red if the amount is >= to $1,000. I am not a...
0
by: TD | last post by:
I have a report that has the MS Graph control on it. I have a query setup for the control. I have a form with 6 check boxes where the user can select which fields they want to appear in the...
1
by: John Dalberg | last post by:
When I change the data source for a report say like from SQL to a stored procedure or if the table fields have changed, all the bound fields on the report vanish. It's time consuming to recreate...
1
by: tony | last post by:
Is there a way to change the "print date" field in vb/vb.net code? I have a report that uses keywords like "MonthToDate" and "YearToDate" to genereate the report, I want to be able to change the...
10
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at...
2
by: tricard | last post by:
Hello all, I have a report that displays four pieces of data by default, but two of these fields are not neccessary for all people to see. I have made a form that gives the user the choice to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...

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.