Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 88
  • Last Modified:

Formatting a Dummy field

Experts,

I have a union query with a dummy field ("" as AmountDummy in the SELECT statement)
This dummy field doesnt conditionally format in my report. (ie the conditional formatting for <0 and turn text red) and the negative sign on the number doesnt go away on any format I apply.  The following is the format I have in the control source on the report:
=Format([AmountDummy],"(#,##0.00)")
and it appears like this: -(25.50) - note the negative sign.

How do I format this field red for a negative number and get rid of the "-" sign and use parenthesis for negatives?

thank you
0
pdvsa
Asked:
pdvsa
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
You pass multiple formats....1st is positive #'s, 2nd negative, 3rd zero, and 4th null, so:

#,##0.00;(#,##0.00)[Red];"Zero";"Null"

Jim
0
 
pdvsaAuthor Commented:
Ok I think I got that but have a follow up.  

It turns the text red, which is what I want but it doesnt remove the "-" sign and there are no parenthesis.  I put the format in the formatting in the space below the control source in the properties sheet.

what do you think is the issue?
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Hum, works fine here.   I opened the VBA editor and the debug window (Ctrl/G) and typed in:

? Format(-123.45,"#,##0.00;(#,##0.00)[Red]")

and got

(123.45)

Jim.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
pdvsaAuthor Commented:
I think this field is a little different since its a dummy field but maybe i should drag the field into the rpt again and test.  Possibly the field has an odd format format since I have been made a few changes to the field.  Will try when i wake up in a few hours because im not in the us now and not in front of computer.
0
 
pdvsaAuthor Commented:
Hi Jim,

Ok back at the computer.  I dragged in a new [AmountDummy] field and applied the format #,##0.00;(#,##0.00)[Red];"Zero";"Null"  as described above but there is no format applied to the field.  

I mentioned in my previous post that the field turns red but after second look it was because of a conditional format I applied (<0 and apply text font color red).

I am sure it is because this field is not a "normal" field like the others because it is dummy.  the  formatting #,##0.00;(#,##0.00)[Red];"Zero";"Null" works on other fields.

the record source is a union if that makes a difference.  thank you.  If you have any other ideas let me know.  

thank you
0
 
PatHartmanCommented:
I'm confused.  If the value of the dummy field is "" which is a zero length string, what is there to format?  If you want it to be zero, make the value zero rather than "".
0
 
Gustav BrockCIOCommented:
I have a union query with a dummy field ("" as AmountDummy in the SELECT statement)
I believe that is your issue. With "" as the dummy value, the values from other sections of the union query also turn into string, thus your output is strings, not numbers.

Try changing the dummy value to Null.
Or you may have to use the union query as source in a new select query. In this you convert your strings to numbers (currency) which you can format as you intend.

/gustav
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<I mentioned in my previous post that the field turns red but after second look it was because of a conditional format I applied (<0 and apply text font color red).>>

  Did you remove the conditional format then?

  and as gustav said, the data type must be correct (numeric)

Jim.
0
 
pdvsaAuthor Commented:
Thank you Gustav.  This is what it was...
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now