Solved

Change Background Color Of Form Based On Data

Posted on 2008-06-22
5
2,655 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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

777 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