Changing the colour of background

  • Thread starter Thread starter Jacob Frankham
  • Start date Start date
J

Jacob Frankham

Hi

I have a report with an OFFICE grouping, and this is where all of my data is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If


But this didn't work !!

Any ideas would be greatly received

Thanks in advance

J
 
Jacob said:
I have a report with an OFFICE grouping, and this is where all of my data is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Hi Marsh

Sorry, by 'didnt work', I mean, the whole page is one complete black square
!

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.

Any ideas?

Cheers

Jake
Marshall Barton said:
Jacob said:
I have a report with an OFFICE grouping, and this is where all of my data is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Jacob said:
Sorry, by 'didnt work', I mean, the whole page is one
complete black square!

Whoa! That sure sounds like the values you assigned to the
variables White and Grey have nonstandard values. You could
try using vbWhite instead of your White variable or try
these definitions:

Dim White As Long
Dim Grey As Long
White = RGB(255, 255, 255)
Grey = RGB( 192, 192, 192)

I'm pretty sure that at least the white part should then
work. If the grey part still comes out black, it may be
that your printer in unable to render grey tones so it makes
any color other than white appear black??

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.

Don't know what number codes you're using, but try the above
and see what happens.
--
Marsh
MVP [MS Access]


Jacob said:
I have a report with an OFFICE grouping, and this is where all of my data is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!
"Marshall Barton" wrote
What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Jacob,
Access doesn't recognize White or Gray as a value, unless you've previously
assigned it a value as a variable.
Otherwise it assumes they are a variable with a value of 0 (which is the
color number for Black).

It does recognize certain VBA Constants, such as
vbWhite, vbRed, vbBlue, etc., but unfortunately vbGray is not one of them.
You'll need to use a gray color number value instead.

Try:

If me.office_Header.Backcolor = vbWhite Then
me.office_Header.Backcolor = 12632256
else
me.office_Header.BackColor = vbWhite
End If

This works for me (assuming the actual name of the section is
'office_Header').
Make sure you use the actual group header name, otherwise you can use
Me.Section(x).BackColor where x is the number of the section header,
probably 5.
 
Two things Marshall:

1) The logic is wrong in that the BG will always be set to grey.
2) Where is Grey defined? Where is White defined? White should be
vbWhite. There is no vbGrey Color Constant so the OP would have to
declare a constant for this value.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Marshall Barton said:
Jacob said:
I have a report with an OFFICE grouping, and this is where all of my data is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Guys

Thanks for all your help

I have tried this:

If Me.office_Header.BackColor = vbWhite Then
Me.office_Header.BackColor = 12632256
Else
Me.office_Header.BackColor = vbWhite
End If

I now have one big grey block (no intermittent white lines)

It is probably worth reinforcing here, that I have nothing in my Detail
section whatsoever, it is minimised up.

Does this make a difference?

Cheers

Jacob Frankham said:
Hi Marsh

Sorry, by 'didnt work', I mean, the whole page is one complete black square
!

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.

Any ideas?

Cheers

Jake
data
is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
That's correct.
The Group Header is formatted once when the group changes.
Each Group Header will consist of only one color.

If you have a group header, let's say of half a page, you'll get a half page
of gray or white, not both. If you wish each record to be alternated colors,
use the Detail section. Use the same code in the Detail Format event to
alternate record backcolors.
The Detail section is formatted for each record in the section.
The Group header should only contain the Group information, not detail
records.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Jacob Frankham said:
Guys

Thanks for all your help

I have tried this:

If Me.office_Header.BackColor = vbWhite Then
Me.office_Header.BackColor = 12632256
Else
Me.office_Header.BackColor = vbWhite
End If

I now have one big grey block (no intermittent white lines)

It is probably worth reinforcing here, that I have nothing in my Detail
section whatsoever, it is minimised up.

Does this make a difference?

Cheers

Jacob Frankham said:
Hi Marsh

Sorry, by 'didnt work', I mean, the whole page is one complete black square
!

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.

Any ideas?

Cheers

Jake
Marshall Barton said:
Jacob Frankham wrote:
I have a report with an OFFICE grouping, and this is where all of my
data
is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Jacob said:
I have tried this:

If Me.office_Header.BackColor = vbWhite Then
Me.office_Header.BackColor = 12632256
Else
Me.office_Header.BackColor = vbWhite
End If

I now have one big grey block (no intermittent white lines)

It is probably worth reinforcing here, that I have nothing in my Detail
section whatsoever, it is minimised up.

Does this make a difference?

It's starting to sound like the code is not in the
office_Header section's Format event. It didn't magically
get moved to the report or page header did it??
--
Marsh
MVP [MS Access]


Hi Marsh

Sorry, by 'didnt work', I mean, the whole page is one complete black square
!

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.
Jacob Frankham wrote:
I have a report with an OFFICE grouping, and this is where all of my
data
is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!
"Marshall Barton" wrote
What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Hi Marsh

No, it remains in office_Header Format event

A previous posting says that my data MUST be in the Detail section for this
to work, so I will try that when I go back to work tomorrow

Cheers

Jake


Marshall Barton said:
Jacob said:
I have tried this:

If Me.office_Header.BackColor = vbWhite Then
Me.office_Header.BackColor = 12632256
Else
Me.office_Header.BackColor = vbWhite
End If

I now have one big grey block (no intermittent white lines)

It is probably worth reinforcing here, that I have nothing in my Detail
section whatsoever, it is minimised up.

Does this make a difference?

It's starting to sound like the code is not in the
office_Header section's Format event. It didn't magically
get moved to the report or page header did it??
--
Marsh
MVP [MS Access]


Hi Marsh

Sorry, by 'didnt work', I mean, the whole page is one complete black square
!

The format event DOES have [Event Procedure] assigned to it.

I have tried also changing white to the respective number code etc, no good.

Jacob Frankham wrote:
I have a report with an OFFICE grouping, and this is where all of my data
is
held (ie nothing in the detail section)

I wish to alternate the background color of each record so that it is
more
readable

I was using in the office_Header_Format event:

If me.office_Header.Backcolor = White Then
me.office_Header.Backcolor = Grey
else
me.office_Header.BackColor = Grey
End If

But this didn't work !!

What did it do? "didn't work" is not very descriptive.

By itself that code looks OK (as long as the section name is
spelled correctly and the OnFormat property contains
[Event Procedure]
 
Back
Top