Conditional Formatting (1 Viewer)

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
Hi All,
not sure how to approach this one.

is it possible to use conditional formatting to format a control to:

If control = 0 then format to Stock
If control = -* then format to Shortage
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
what do you mean by format? 'Stock' is not a format

and are you mixing datatypes? 0 is numeric -* is text
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
if a value in a control is 0, i want to display Stock in the control and not the actual value
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
use the formart property - for numbers there are 4 options, positive, negation, zero and null, separated by a semi colon.

don't know what other values you have but perhaps something like this

0.00;0.00;[red]"Stock"
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
use the formart property - for numbers there are 4 options, positive, negation, zero and null, separated by a semi colon.

don't know what other values you have but perhaps something like this

0.00;0.00;[red]"Stock"
please could you explain how to do this.
do i still use conditional formatting - field value is?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:32
Joined
May 21, 2018
Messages
8,527
You can do something like this. I do not think you can use the format property to handle 0. I have two textboxes on top of each other to make this work.
 

Attachments

  • Database5.accdb
    408 KB · Views: 114

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
please could you explain how to do this.
one of the control properties is format - just copy paste the code I provided into it
do i still use conditional formatting - field value is?
No

@MajP I do not think you can use the format property to handle 0 - yes, you can.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
then use this if I have more options such as stock or shortage or if i need to add more?
As I've said there are 4 states for numbers, so assuming your shortage is indicated by a negative value then use

0.00;[red]"Shortage";[red]"Stock"


note the [red] is not necessary - but just acts as a warning. Google 'access format property' to find out more
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:32
Joined
May 21, 2018
Messages
8,527
@MajP I do not think you can use the format property to handle 0 - yes, you can
I see it is both zero and null, not just null. Thanks.
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
You can do something like this. I do not think you can use the format property to handle 0. I have two textboxes on top of each other to make this work.
i get an operand without an operator error

#=IIf([FieldValue]=0,"Stock",[FieldValue])#

# =IIf([Shortage]>0,"Shortage",[Shortage]) #
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
here are some things you can do with the format property

 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
one of the control properties is format - just copy paste the code I provided into it
No

@MajP I do not think you can use the format property to handle 0 - yes, you can.
[0].[00;red]"Status";[red"Stock"]

1596458456403.png


how do it for >0 vlaues?
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
this is what I have tried

# =iff([OTR5C QRY]![Stock Avilable]>[OTR5C QRY]![Reqmt Qty1],"Stock") #

# =iff([OTR5C QRY]![Stock Avilable]<[OTR5C QRY]![Reqmt Qty1],"Shortage") #

but i get a #Name? error
 
Last edited:

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
I've no idea where you are going with my suggestion - the code you are using a) seems to be in the wrong place and b) is nothing like what I provided.


this
[0].[00;red]"Status";[red"Stock"]

should look like this

0.00;[red]"Status";[red]"Stock"

Suggest you go with MajP's suggestion since I suspect I do not understand what it is you actually require - you seem to be wanting to reference other fields or controls
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
I've no idea where you are going with my suggestion - the code you are using a) seems to be in the wrong place and b) is nothing like what I provided.


this
[0].[00;red]"Status";[red"Stock"]

should look like this

0.00;[red]"Status";[red]"Stock"

Suggest you go with MajP's suggestion since I suspect I do not understand what it is you actually require - you seem to be wanting to reference other fields or controls
yes, i need to compare other fields to the 2 different scenarios

thank you
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:32
Joined
Sep 21, 2011
Messages
14,265
I believe the o/p is wanting to change the data in the control. Nothing to do with Format, though that is mentioned?
if a value in a control is 0, i want to display Stock in the control and not the actual value
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:32
Joined
Feb 19, 2013
Messages
16,607
if a value in a control is 0, i want to display Stock in the control and not the actual value
which is what you would use the format property for - solution already provided
 

Gismo

Registered User.
Local time
Tomorrow, 01:32
Joined
Jun 12, 2017
Messages
1,298
this is what I have tried

# =iff([OTR5C QRY]![Stock Avilable]>[OTR5C QRY]![Reqmt Qty1],"Stock") #

# =iff([OTR5C QRY]![Stock Avilable]<[OTR5C QRY]![Reqmt Qty1],"Shortage") #

but i get a #Name? error
above is what I tried

i need to display on a form "Stock" if my available stock is more than my required stock
if the required stock is more than available stock "Shortage" must be displayed
 

Users who are viewing this thread

Top Bottom