Microsoft KB Archive/250981

= PRB: Merged FoxPro Table Fields Display Incorrectly in Microsoft Word =

Article ID: 250981

Article Last Modified on 5/10/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q250981



SYMPTOMS
The Mail Merge feature of Microsoft Word does not properly display numeric and currency fields that are merged from Microsoft Visual FoxPro tables.



RESOLUTION
To display merged numbers correctly, you must use Format Masking. To format the results of a mail merge, you must use the numeric picture switch in the MERGEFIELD field code as shown here:
 * 1) Open the main document in Microsoft Word.
 * 2) Display the field codes by pressing ALT+F9.
 * 3) For all the merge fields that display numeric or currency fields, which do not have decimal places, change the field code as follows: { MERGEFIELD fieldname \# #,###,###.00 }


 * 1) Press ALT+F9 to toggle the view to show field results instead of field codes.
 * 2) Run the merge again to a new document to get the correct results.



MORE INFORMATION
If the merged numeric and currency fields do not have any decimal values, they display with only a decimal point to the right of them. For example "12345.00" displays as "12345.".

Steps To Reproduce Behavior
  Run Visual FoxPro. Create and populate a table as follows: CREATE TABLE MrgTest (Fld1 c(5), Fld2 n(8,2), Fld3 y)  INSERT INTO MrgTest VALUES("AAAAA", 12345.11, 2345.11) INSERT INTO MrgTest VALUES("BBBBB", 67890.00, 6789.00)  Close the table and then close Visual FoxPro. Make sure that Microsoft Query is installed on your computer by searching for Msqrv32.exe on your computer. If Microsoft Query is not installed, then run the Microsoft Office setup to install Microsoft Query. Use the ODBC Manager and create a data source based on the Microsoft Visual FoxPro ODBC Driver for the Visual FoxPro table you created in the first step. Name the data source VFPMrgTest. Run Microsoft Word and open a new document. From the Tools menu, click Mail Merge to open the Mail Merge Helper dialog box. In the Mail Merge Helper dialog box, click the Create command button and then click the document type that you want. In the next dialog box, click the Active Window command button.</li> In the Mail Merge Helper dialog box, click the Get Data command button, and then click Open Data Source.</li> In the Open Data Source dialog box, in the Files of type combo box click "MS FoxPro Files". Locate the Visual FoxPro table you created in the first step and highlight the table name. Click the Open command button in the bottom right corner of the Open Data Source dialog box.</li> In the Confirm Data Source dialog box, click "FoxPro File - Word via ODBC(*.dbf)", and then click OK. In the next dialog box, click Set Up Main Document. In the Label Options dialog box, select the label type and then click OK.</li> Click the Insert Merge Fields command button and insert all the fields in the table from the Create Labels dialog box and then click OK.</li> In the Mail Merge Helper dialog box, click Merge. In the Merge dialog box, click New Document as the "Merge To" option and then click Merge.</li></ol>

Note that the numeric and currency fields that do not have decimal values display incorrectly. For example "6789.00" shows as "6789."

<div class="references_section">