Mark fields in a report with an * based on certain criteria. (1 Viewer)

spet

Registered User.
Local time
Today, 00:21
Joined
Oct 5, 2018
Messages
38
Hello, I understand I can highlight a field with conditional formatting but I am looking to asterisk fields based on criteria of the field.

Ex. I have a text box txtNumber

If txtNumber <> between 3 and 5, then I would like to display the Number with an * next to it, otherwise just the number. Thoughts?

I've tried:

IIF(txtNumber <> Between 3 and 5, txtNumber & " *", txtNumber)

And I receive #Type Error.

Any thoughts on how I can accomplish this?

Thank you in advance
 

June7

AWF VIP
Local time
Yesterday, 21:21
Joined
Mar 9, 2014
Messages
5,465
Try:

IIf(txtNumber BETWEEN 3 AND 5, txtNumber, txtNumber & " *")

or

IIf(txtNumber NOT BETWEEN 3 AND 5, txtNumber & " *", txtNumber)

or

=txtNumber & IIf(txtNumber NOT BETWEEN 3 AND 5, "*", "")

or if you would like txtNumber to remain a number instead of part of a string, do the IIf() of the last example in another textbox. The * would then be more eye-catching and numbers would right align.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:21
Joined
Sep 21, 2011
Messages
14,231
Not sure you can use Between like that?
You can use Cstr() and & "*" for append perhaps?

I'd use >=3 and <=5
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:21
Joined
Oct 29, 2018
Messages
21,454
I would just do it in the query as a calculated column.
 

isladogs

MVP / VIP
Local time
Today, 06:21
Joined
Jan 14, 2017
Messages
18,209
As June suggested, I would do this as a separate textbox next to your number textbox.
The * would be made visible if your conditions were met and hidden otherwise.
One advantage of this method is the * can be formatted differently e.g. Bold & red
 

June7

AWF VIP
Local time
Yesterday, 21:21
Joined
Mar 9, 2014
Messages
5,465
Not sure you can use Between like that?
You can use Cstr() and & "*" for append perhaps?
Yes, BETWEEN AND does work in ControlSource expression. CStr() is not necessary.
 

spet

Registered User.
Local time
Today, 00:21
Joined
Oct 5, 2018
Messages
38
Thank you all! txtNumber was actually intNumber and the error I was receiving was trying to convert the integer to a string. I went ahead as June suggested to create a seperate textbox and it works great!

Thank you :)
 

Users who are viewing this thread

Top Bottom