Conditional Format problem

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

If tbAdditionCharge is Null and tbAdditionAmount is more than 1 condition
should be meet but it does not with this code???

IsNull([tbAdditionCharge]) And [tbAdditionChargeAmount]>0
 
Try replacing the AND with an OR:

IsNull([tbAdditionCharge]) OR [tbAdditionChargeAmount] > 0

Also, sometimes, you must use the Is Null operator (with a blank space)
instead of the IsNull() function:

([tbAdditionCharge] Is Null) OR [tbAdditionChargeAmount] > 0

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)
 
Sorry, I misread your post as I can see now that you are using two
differents fields: [bAdditionCharge]and [bAdditionChargeAmount] (to much
multi-tasking) so my suggestion about replacing the AND with an OR is not OK
but you can still take a look at replacing the IsNull() function with the Is
Null operator.

Also, you make a mention of [tbAdditionAmount] in your explanation but you
have wrote [tbAdditionChargeAmount] in your code snippet. Which one is
good?

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


Sylvain Lafontaine said:
Try replacing the AND with an OR:

IsNull([tbAdditionCharge]) OR [tbAdditionChargeAmount] > 0

Also, sometimes, you must use the Is Null operator (with a blank space)
instead of the IsNull() function:

([tbAdditionCharge] Is Null) OR [tbAdditionChargeAmount] > 0

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


Bob Vance said:
If tbAdditionCharge is Null and tbAdditionAmount is more than 1 condition
should be meet but it does not with this code???

IsNull([tbAdditionCharge]) And [tbAdditionChargeAmount]>0
 
Thanks Sylvain, but neither code worked of yours , I looked at my first post
and it is correctly worded, if tbAdditionCharge is null and
tbadditionChargeAmount is more than 0 condition to make background "Red" of
tbAdditionCharge
Thanks Bob

Sylvain Lafontaine said:
Sorry, I misread your post as I can see now that you are using two
differents fields: [bAdditionCharge]and [bAdditionChargeAmount] (to much
multi-tasking) so my suggestion about replacing the AND with an OR is not
OK but you can still take a look at replacing the IsNull() function with
the Is Null operator.

Also, you make a mention of [tbAdditionAmount] in your explanation but you
have wrote [tbAdditionChargeAmount] in your code snippet. Which one is
good?

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


Sylvain Lafontaine said:
Try replacing the AND with an OR:

IsNull([tbAdditionCharge]) OR [tbAdditionChargeAmount] > 0

Also, sometimes, you must use the Is Null operator (with a blank space)
instead of the IsNull() function:

([tbAdditionCharge] Is Null) OR [tbAdditionChargeAmount] > 0

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


Bob Vance said:
If tbAdditionCharge is Null and tbAdditionAmount is more than 1
condition should be meet but it does not with this code???

IsNull([tbAdditionCharge]) And [tbAdditionChargeAmount]>0
 
Just want to confirm you used
Expression Is
and then entered
[tbAdditionCharge] Is Null And [tbAdditionChargeAmount],0 > 0
and both fields (not controls) are available in the record source of the form
or report.

What field type is tbAdditionCharge? If it is a text field it is possible
that it contains a zero-length string instead of null. You might try
([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount],0 > 0

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Thanks John tbAdditionalCharge is Text
tbAdditionChargeAmount is Currency
Both are record source is a table
I am using Expression Is
With your code I am getting Invalid Syntax you must enclose your text data
in Quotes
Thanks Bob

John Spencer said:
Just want to confirm you used
Expression Is
and then entered
[tbAdditionCharge] Is Null And [tbAdditionChargeAmount],0 > 0
and both fields (not controls) are available in the record source of the
form or report.

What field type is tbAdditionCharge? If it is a text field it is possible
that it contains a zero-length string instead of null. You might try
([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount],0 > 0

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Thanks Sylvain, but neither code worked of yours , I looked at my first
post and it is correctly worded, if tbAdditionCharge is null and
tbadditionChargeAmount is more than 0 condition to make background "Red"
of tbAdditionCharge
Thanks Bob
 
That is strange. I'm not at all sure what that error message is saying. Since
if you entered it as I posted it the only thing that could be interpreted
would be the two quote marks. I am assuming you didn't attempt to enter four
single quotes or leave off the brackets around the field names.

I just tested the following expression on one of my sample databases and it
behaves as expected and I am not getting any error (Access 2003).

[fLink] Is Null Or [fLink]=""

I did notice that somehow what I posted seems to have a Picked up an extra
comma and zero. What I meant to post was the following (all on one line)

([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount] > 0

You might try testing out the conditional formatting by putting in just one of
the comparisons and see if that works. If it does add another.

Try
[tbAdditionCharge] Is Null

Then

[tbAdditionCharge] Is Null or [tbAdditionCharge] = ""

Then
[tbAdditionChargeAmount] > 0

And finally

([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount] > 0


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Thanks John tbAdditionalCharge is Text
tbAdditionChargeAmount is Currency
Both are record source is a table
I am using Expression Is
With your code I am getting Invalid Syntax you must enclose your text data
in Quotes
Thanks Bob

John Spencer said:
Just want to confirm you used
Expression Is
and then entered
[tbAdditionCharge] Is Null And [tbAdditionChargeAmount],0 > 0
and both fields (not controls) are available in the record source of the
form or report.

What field type is tbAdditionCharge? If it is a text field it is possible
that it contains a zero-length string instead of null. You might try
([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount],0 > 0

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Thanks Sylvain, but neither code worked of yours , I looked at my first
post and it is correctly worded, if tbAdditionCharge is null and
tbadditionChargeAmount is more than 0 condition to make background "Red"
of tbAdditionCharge
Thanks Bob
 
No Error John, But does not change conditioning

This what I have in tbAdditionChargeAmount that works fine!



[tbAdditionChargeAmount]="0" And Not IsNull([tbAdditionCharge])



May be I should look to not saving record if tbAdditionCharge is Null and
tbAdditionChargeAmount is >0 ????

Regards Bob



John Spencer said:
That is strange. I'm not at all sure what that error message is saying.
Since if you entered it as I posted it the only thing that could be
interpreted would be the two quote marks. I am assuming you didn't
attempt to enter four single quotes or leave off the brackets around the
field names.

I just tested the following expression on one of my sample databases and
it behaves as expected and I am not getting any error (Access 2003).

[fLink] Is Null Or [fLink]=""

I did notice that somehow what I posted seems to have a Picked up an extra
comma and zero. What I meant to post was the following (all on one line)

([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount] > 0

You might try testing out the conditional formatting by putting in just
one of the comparisons and see if that works. If it does add another.

Try
[tbAdditionCharge] Is Null

Then

[tbAdditionCharge] Is Null or [tbAdditionCharge] = ""

Then
[tbAdditionChargeAmount] > 0

And finally

([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount] > 0


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Thanks John tbAdditionalCharge is Text
tbAdditionChargeAmount is Currency
Both are record source is a table
I am using Expression Is
With your code I am getting Invalid Syntax you must enclose your text
data in Quotes
Thanks Bob

John Spencer said:
Just want to confirm you used
Expression Is
and then entered
[tbAdditionCharge] Is Null And [tbAdditionChargeAmount],0 > 0
and both fields (not controls) are available in the record source of the
form or report.

What field type is tbAdditionCharge? If it is a text field it is
possible that it contains a zero-length string instead of null. You
might try
([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount],0 > 0

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob Vance wrote:
Thanks Sylvain, but neither code worked of yours , I looked at my first
post and it is correctly worded, if tbAdditionCharge is null and
tbadditionChargeAmount is more than 0 condition to make background
"Red" of tbAdditionCharge
Thanks Bob
 
Is tbAdditionChargeAmount a number field or a text field? Your posted
condition indicates that it is a text field (="0").

I can't figure out why you are having the problem with conditional formatting.
Perhaps the form/report has some slight corruption.

Have you tried to decompile the database?

You can use the decompile method to attempt a fix.

Check out the articles at:

http://www.trigeminal.com/usenet/usenet004.asp

http://www.mvps.org/access/bugs/bugs0008.htm

They are written for Access97 (the same method works for Access2000 and
Access2002, 2003, and I believe for 2007).

Be sure to MAKE A COPY of your mdb before you decompile. I've never had any
trouble but . . .

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
John I think you are getting the 2 text boxes mixed up tbAdditionCharge is
Text field and tbAdditionAmount is Currency
The example I posted was in the other text box that works fine
Regards Bob, I have compiled!

John Spencer said:
Is tbAdditionChargeAmount a number field or a text field? Your posted
condition indicates that it is a text field (="0").

I can't figure out why you are having the problem with conditional
formatting. Perhaps the form/report has some slight corruption.

Have you tried to decompile the database?

You can use the decompile method to attempt a fix.

Check out the articles at:

http://www.trigeminal.com/usenet/usenet004.asp

http://www.mvps.org/access/bugs/bugs0008.htm

They are written for Access97 (the same method works for Access2000 and
Access2002, 2003, and I believe for 2007).

Be sure to MAKE A COPY of your mdb before you decompile. I've never had
any trouble but . . .

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
No Error John, But does not change conditioning

This what I have in tbAdditionChargeAmount that works fine!



[tbAdditionChargeAmount]="0" And Not IsNull([tbAdditionCharge])



May be I should look to not saving record if tbAdditionCharge is Null and
tbAdditionChargeAmount is >0 ????

Regards Bob
 
John Spencer said:
Just want to confirm you used
Expression Is
and then entered
[tbAdditionCharge] Is Null And [tbAdditionChargeAmount],0 > 0
and both fields (not controls) are available in the record source of the
form or report.

What field type is tbAdditionCharge? If it is a text field it is possible
that it contains a zero-length string instead of null. You might try
([tbAdditionCharge] Is Null or [tbAdditionCharge] = "") And
[tbAdditionChargeAmount],0 > 0

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Bob said:
Thanks Sylvain, but neither code worked of yours , I looked at my first
post and it is correctly worded, if tbAdditionCharge is null and
tbadditionChargeAmount is more than 0 condition to make background "Red"
of tbAdditionCharge
Thanks Bob
 
Back
Top