A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional Formatting through VBA works in print preview but nowhere else!



 
 
Thread Tools Display Modes
  #1  
Old April 28th, 2010, 11:57 PM posted to microsoft.public.access.gettingstarted
orographicfish via AccessMonster.com
external usenet poster
 
Posts: 2
Default Conditional Formatting through VBA works in print preview but nowhere else!

I'm trying to put together a report in Access 2007 where the detail record is
displayed as a different background color depending on the value of a field.
There are more than 3 conditions, so I've opted to attempt this via VBA. It
works- but only in print preview.... Why? I can't figure out what I'm doing
wrong. I'm sure it's something simple, but I'd really appreciate some help
on this one.

Code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Select Case Me![Status]
Case 8
Me![Text43].BackColor = RGB(165, 165, 79)
Me![Text43].BackStyle = 1

Case 1
Me![Text43].BackColor = vbCyan
Me![Text43].BackStyle = 1
Case 2 To 3
Me![Text43].BackColor = vbRed
Me![Text43].BackStyle = 1
Case 4, 5, 7
Me![Text43].BackColor = vbGreen
Me![Text43].BackStyle = 1
Case Else
Me![Text43].BackColor = vbYellow
Me![Text43].BackStyle = 1
End Select
End Sub

--
Message posted via http://www.accessmonster.com

  #2  
Old April 29th, 2010, 02:44 AM posted to microsoft.public.access.gettingstarted
Duane Hookom[_4_]
external usenet poster
 
Posts: 316
Default Conditional Formatting through VBA works in print preview but nowhere else!

Code will only run in Print and Print Preview modes.

--
Duane Hookom
MS Access MVP


"orographicfish via AccessMonster.com" u57931@uwe wrote in message
news:a73a06dcdb5c5@uwe...
I'm trying to put together a report in Access 2007 where the detail record
is
displayed as a different background color depending on the value of a
field.
There are more than 3 conditions, so I've opted to attempt this via VBA.
It
works- but only in print preview.... Why? I can't figure out what I'm
doing
wrong. I'm sure it's something simple, but I'd really appreciate some
help
on this one.

Code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Select Case Me![Status]
Case 8
Me![Text43].BackColor = RGB(165, 165, 79)
Me![Text43].BackStyle = 1

Case 1
Me![Text43].BackColor = vbCyan
Me![Text43].BackStyle = 1
Case 2 To 3
Me![Text43].BackColor = vbRed
Me![Text43].BackStyle = 1
Case 4, 5, 7
Me![Text43].BackColor = vbGreen
Me![Text43].BackStyle = 1
Case Else
Me![Text43].BackColor = vbYellow
Me![Text43].BackStyle = 1
End Select
End Sub

--
Message posted via http://www.accessmonster.com

  #3  
Old April 29th, 2010, 03:50 PM posted to microsoft.public.access.gettingstarted
orographicfish via AccessMonster.com
external usenet poster
 
Posts: 2
Default Conditional Formatting through VBA works in print preview but nowhere else!

Is there a way to conditionally format the background appearance of the
detail section based on a field's value in Report View? I need this to work
for display- not just for printing.

Duane Hookom wrote:
Code will only run in Print and Print Preview modes.

I'm trying to put together a report in Access 2007 where the detail record
is

[quoted text clipped - 31 lines]
End Select
End Sub


--
Message posted via http://www.accessmonster.com

  #4  
Old April 30th, 2010, 04:36 AM posted to microsoft.public.access.gettingstarted
Duane Hookom[_4_]
external usenet poster
 
Posts: 316
Default Conditional Formatting through VBA works in print preview but nowhere else!

Use the print preview.

--
Duane Hookom
MS Access MVP


"orographicfish via AccessMonster.com" u57931@uwe wrote in message
news:a74257932e8df@uwe...
Is there a way to conditionally format the background appearance of the
detail section based on a field's value in Report View? I need this to
work
for display- not just for printing.

Duane Hookom wrote:
Code will only run in Print and Print Preview modes.

I'm trying to put together a report in Access 2007 where the detail
record
is

[quoted text clipped - 31 lines]
End Select
End Sub


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.