473,406 Members | 2,467 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,406 software developers and data experts.

Conditional Formatting Error

I am trying to add more than three conditional formatting conditions such that
If the Moisture values is > 3.5 it turns the text box = Red
is between 2.35 - 3.25 , the text box = Green
is > 3.25 and < 3.5 = Yellow
is < 2.35 and >2.10 = Yellow
is < 2.10 = Red
How can i write a Code for the same ?

I tried this code but it asks me for the text range, can someone help me resolve this issue please ?

Expand|Select|Wrap|Line Numbers
  1. Select Case Me![txtRange]
  2.   Case Is > 3.5
  3.      Me![txtMoisture Values].ForeColor = vbRed
  4.   Case 2.35 To 3.5
  5.      Me![txtMoisture Values].ForeColor = vbGreen
  6.   Case 2.10 To 2.34
  7.      Me![txtMoisture Values].ForeColor = vbYellow
  8.   Case Is < 2.1
  9.      Me![txtMoisture Values].ForeColor = vbRed
  10.   Case Else
  11.      Me![txtMoisture Values].ForeColor = vbBlack
  12. End Select
May 14 '07 #1
5 1534
Rabbit
12,516 Expert Mod 8TB
I am trying to add more than three conditional formatting conditions such that
If the Moisture values is > 3.5 it turns the text box = Red
is between 2.35 - 3.25 , the text box = Green
is > 3.25 and < 3.5 = Yellow
is < 2.35 and >2.10 = Yellow
is < 2.10 = Red
How can i write a Code for the same ?

I tried this code but it asks me for the text range, can someone help me resolve this issue please ?

Select Case Me![txtRange]
Case Is > 3.5
Me![txtMoisture Values].ForeColor = vbRed
Case 2.35 To 3.5
Me![txtMoisture Values].ForeColor = vbGreen
Case 2.10 To 2.34
Me![txtMoisture Values].ForeColor = vbYellow
Case Is < 2.1
Me![txtMoisture Values].ForeColor = vbRed
Case Else
Me![txtMoisture Values].ForeColor = vbBlack
End Select
Why not just use the conditional formatting wizard?

[txtRange] should be [txtMoistureValues]
May 17 '07 #2
ADezii
8,834 Expert 8TB
I am trying to add more than three conditional formatting conditions such that
If the Moisture values is > 3.5 it turns the text box = Red
is between 2.35 - 3.25 , the text box = Green
is > 3.25 and < 3.5 = Yellow
is < 2.35 and >2.10 = Yellow
is < 2.10 = Red
How can i write a Code for the same ?

I tried this code but it asks me for the text range, can someone help me resolve this issue please ?

Select Case Me![txtRange]
Case Is > 3.5
Me![txtMoisture Values].ForeColor = vbRed
Case 2.35 To 3.5
Me![txtMoisture Values].ForeColor = vbGreen
Case 2.10 To 2.34
Me![txtMoisture Values].ForeColor = vbYellow
Case Is < 2.1
Me![txtMoisture Values].ForeColor = vbRed
Case Else
Me![txtMoisture Values].ForeColor = vbBlack
End Select
As previously stated on several occassions, [txtRange] and [txtMoisture Values] are Field names that I used solely for demonstration purposes. You must substitute your own Field Names.
May 18 '07 #3
puppydogbuddy
1,923 Expert 1GB
I've had this problem before. If I remember correctly the value in the textboxes have to be converted to Double precision using CDbl before the Select case can deal wiith them as decimal fractions.

Expand|Select|Wrap|Line Numbers
  1. Me![txtRange].Value = CDbl(Me![txtRange])
  2. Me![txtMoistureLevels].Value = CDbl(Me![txtMoistureLevels])
  3.  
  4. Select Case Me![txtRange]
-----------

It might be worth a try here.
May 23 '07 #5
ADezii
8,834 Expert 8TB
I've had this problem before. If I remember correctly the value in the textboxes have to be converted to Double precision using CDbl before the Select case can deal wiith them as decimal fractions.

Me![txtRange].Value = CDbl(Me![txtRange])
Me![txtMoistureLevels].Value = CDbl(Me![txtMoistureLevels])

Select Case Me![txtRange]
-----------

It might be worth a try here.
We initially went over this ground where Moisture Values and Range were stored internally as SINGLE Precision Numbers. The Text Boxes referring to these Fields should return Variants of SubType SINGLE which should not pose any problem with the Select Case Statement. It is a very good point that definately should be double checked.
May 24 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
2
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
3
by: DS | last post by:
I have a Field that reads #Error, sometimes...I want to use conditional formatting to hide the field when it reads #Error...so in conditional formatting I put - when field equals "#Error" , but it...
2
by: jodyblau | last post by:
I'm not certain that what I am trying to do is possible; in any event I haven't been able to figure it out. Here is what I am trying to do: I have one table that has a list of cases I'm working...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
2
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.