Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

DisplayFormat question

edited October 2014 in General
DXE5, RBE15.04

I have several currency fields in many of my reports. I've had users
request that only "balance" fields use parentheses for negative/credit
balances; all others they want to see in the form -$1.11 for negative
values. I thought this would be a simple matter.

So far, I've set every DisplayFormat property for every field
appropriately in all reports, either '$#,0.00;($#,0.00)' for balances or
'$#,0.00;-$#,0.00' for other fields. I've also done the same in every
field in every associated dataset. FYI, the Windows regional settings
default to '($1.1)' for negative currency values.

Unfortunately, none of the explicit DisplayFormat settings seem to have
an affect where needed. ALL negative numbers ALWAYS display in ($1.11)
format regardless, causing me to think that RB is over-riding the
explicit settings in favor of the Windows regional settings.

Is there any way to force RB to use the ppDBField's DisplayFormat settings?

Thanks very much.

Comments

  • edited October 2014
    HFox wrote:


    I usually only have to set DisplayFormat in the ppDBFields to change
    formatting. Have you tried without also setting the dataset fields?
    What's the underlying database, what database controls are you using
    (TClientDataSet or ??), and what is the actual field type?

    Note that if it *is* actually related to locale settings, you can
    modify the settings in the application.

    (uses System.Sysutils for FormatSettings)

    Check out what FormatSettings.NegCurrFormat is set to by default, then
    try adjusting to see if that helps.

    http://docwiki.embarcadero.com/Libraries/XE3/en/System.SysUtils.TFormatSettings.NegCurrFormat

    Note that if you change the global FormatSettings, you ALSO have to
    update ppFormatSettings (uses ppUtils) - e.g.:

    FormatSettings.NegCurrFormat := 0;
    ppFormatSettings := FormatSettings;

    If this application writes data, I'd want to check that changing the
    FormatSettings doesn't do something weird to data being written
    (paranoia is a way of life).


    Cheers,
    EdB
  • edited October 2014
    Hello,

    Take a look at the ppDisplayFormat.pas file for how ReportBuilder
    handles display formats. By default ReportBuilder honors the Windows
    Currency formatting settings.

    It is possible to replace this behavior and register your own using the
    global variable gcDisplayFormat. See the following article on currency
    formatting in ReportBuilder.

    http://www.digital-metaphors.com/rbWiki/Design/Formatting/Currency_Formatting



    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2014
    Thanks, Nico (and Ed),

    I'm afraid I still don't quite understand how I can use the provided
    information on a field-by-field basis. As I mentioned originally, the
    only part of the currency display format that I want to change is the
    negative value format. That is, for certain ppDBText fields I'd like
    values to appear as ($1,234.56) while others appear as -$1,234.56. As
    odd as this seems, my users (old school accountant types) only want to
    see negative/credit account 'balances' in parentheses; other values that
    affect the balances negatively, they'd like to see with just the minus
    sign. Inasmuch as I can right click on any such DBText field, and pick,
    among others, either '$#,0.00;($#,0.00)' or '$#,0.00;-$#,0.00' from the
    DisplayFormat menu, I expected each field would be displayed with their
    selected format. In fact, there are numerous examples in the RB
    Developer's Guide that give instructions to set DBText DisplayFormats to
    a variety of options. Forgive me if I'm not understanding the obvious,
    but what am I missing here?

  • edited October 2014
    ReportBuilder does not use the DisplayFormat of the field, it uses the
    DisplayFormat of the DBText component.

    If you would like to alter the DisplayFormat of a currency field, you
    will need to follow the instructions in the article I posted previously
    and alter the DisplayFormat property of the DBText component you are using.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2014
    Thanks, again, Nico,

    I think I'm not having much luck making my issue clear...

    I don't need or want to globally change any of the formatting. I merely
    want to use two of the different formats that RB offers already for the
    numeric DBText fields in my reports.

    For example:

    ppPipeline1.DataSource := DS1;
    ppReport1.Pipeline := ppPipeline1;
    ppReport1.DBText1.DisplayFormat := '$#,0.00;($#,0.00)';
    ppReport1.DBText2.DisplayFormat := '#,0,00;-#,0.00';

    Both/all of the field's DisplayFormat properties are set in the RB
    Designer by right-clicking the report field and selecting
    DisplayFormat... from the menu, then selecting the desired format.

    Unfortunately, at report time, DBText2 and all other DBText fields using
    that same DisplayFormat are printed using the format specified for
    DBText1. This occurs no matter what format I choose for DBText2 and
    other similar fields.

    I have no idea why RB insists on using only one of the formats for every
    DBText (numeric) field in the report. I have even tried, without
    success, to specify the DisplayFormat in the Pipeline field properties.
    I've also examined the text version of the ppReport template to make
    sure the different display formats for each field are being saved, which
    they are. Still, RB prints every DBText field with the same format.

    Your ideas would, again, be appreciated.



This discussion has been closed.