For a mail merge in Microsoft Word from data in Microsoft Excel, I have written a DATABASE field that successfully adds all of the fields I want and dynamically changes for each mail merge record ("many to one").
I have then tried to format the numbers within this DATABASE statement, but when I used FORMAT()
the number did change to the format I wanted, however the header was replaced with Expr1003
.
Is there a way to format the numbers within the DATABASE statement shown below but without losing the header titles?
Code without formatting:
{DATABASE \d"{FILENAME \p}/../data5.xlsx" \s "SELECT [Accountable Officer], [Cost Centre Group], [Description], [Annual Budget], [Outturn Forecast], [Outturn Forecast Variance] FROM [data$] WHERE [Accountable Officer] = {Quote 39}{MERGEFIELD Accountable_Officer}{Quote 39} ORDER BY [Cost Centre Group] "\l \b "16" \h}
If I amend Annual Budget with FORMAT()
as below:
{DATABASE \d"{FILENAME \p}/../data5.xlsx" \s "SELECT [Accountable Officer], [Cost Centre Group], [Description], FORMAT([Annual Budget], '£#,##0;-£#,##0'), [Outturn Forecast], [Outturn Forecast Variance] FROM [data$] WHERE [Accountable Officer] = {Quote 39}{MERGEFIELD Accountable_Officer}{Quote 39} ORDER BY [Cost Centre Group] "\l \b "16" \h}
then the figures shown in the Annual Budget column are formatted correctly, but the header title then changes to Expr1003
(or Expr1004
, Expr1006
etc).