Solved

Change Background Color Of Form Based On Data

Posted on 2008-06-22
5
2,668 Views
Last Modified: 2013-11-28
Hey Experts, I am asking this on behalf of a friend.
She wants to change the color of a form in an access 2003 database if it is overdue?
we found:
   if me.yourformfield > aCertainnumber then
       detail.backcolor = vbred  
    else
       detail.backcolor = 16777215
    end if

at http://forums.aspfree.com/microsoft-access-help-18/change-background-color-of-form-based-on-data-215704.html
however it causes all the forms to change colour.

Any help would be muchly appreciated.
0
Comment
Question by:NttNschu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 21843860
Hello NttNschu,

Have a look at Conditional Formatting.

Regards,

Patrick
0
 
LVL 14

Expert Comment

by:ldunscombe
ID: 21844680
I don't understand why you are having a problem.

I tested this in the OnCurrent event of one of my forms and it worked no problem.

  If Me.ID > 15 Then
       Detail.BackColor = vbRed
    Else
       Detail.BackColor = 16777215
    End If

All I would ask is Where are you putting your code.

Leigh
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21845014
NttNschu,

<however it causes all the forms to change colour.>

First, I think you mean, you have a continuous form, and all the *records* are the same color.

What you are asking is difficult to do with a continous form.
You can look here if you are good with modifying vba code:
http://www.lebans.com/alternatecolordetailsection.htm


If I were you, I would just set the "Control" to change color.
Use conditional formatting for this as matthewspatrick suggested.

Select Your Form Field, then Click: Format-->Conditional formatting
Box1: If Field Value is
Box 2: Equal to
Box 3:  A_Certain_Value

The just set the BackColor to Red.

Give the points to matthewspatrick, if you decide to go with this technique.

JeffCoachman
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 21849889
I agree if you are using a continious form then try conditional formatting. Maybe just set one of the fields backcolor to red.
0
 
LVL 1

Author Comment

by:NttNschu
ID: 21851022
Thanks Heaps for your help guys.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question