Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

13.16 Re-Mapping Fields

Re-mapping Fields

When replacing one table with another table, it is possible that one or more of the fields on the report won’t have exact matches in the new table. If the fields in a table are renamed or deleted, this can affect the existing fields on your report. When this happens, Crystal Reports gives you the option to remap the existing fields to the new fields in the database.

After using the Set Location dialog box or when using the Verify Database function, Crystal Reports checks if any changes have been made to the table. If it detects that a change has occurred that effects fields being used on the report, it opens the Map Fields dialog box shown in Figure 13-9. It shows the fields that don’t have a matching field in the current table. It also shows you the new fields in the data source so that you can match the old fields to the new fields. Crystal replaces them accordingly.



Figure 13-9. The Map Fields dialog box.

There is no way to open the Map Fields dialog box directly. It only opens in response to another action. For example, you have to open it indirectly by choosing the menu options Verify Database or Set Location.

This dialog box is only displayed when necessary. If changes are made to fields that have not been added to the report yet, then it isn’t necessary to re-map these fields. Fields that only have their data types changed are not mapped either, but you should check their output when the report runs to make sure they are formatted properly.

The Map Fields dialog box is divided into two halves. The top half shows the unmapped fields. The left-most window shows the fields that are in the report but don’t have a matching field in its assigned table. The right-most window shows all the fields from the currently selected tables. Select one of the unmapped fields in the left window and then select one of the available fields in the right window. Click on the Map button to replace the old field with the new field. You might notice that not all the fields are listed in the right-most window. This is because the checkbox to the right, labeled “Match type” is checked by default. This requires you to only match fields that have the same data type. It won’t list the fields that don’t have the same data type. If you uncheck this checkbox then all fields are displayed and you can replace a field with a field of a different data type. If you do this you should go back to the report and make sure that the formatting and spacing of the new field are appropriate. The formatting of the old field may not have carried over properly.

If there are fields that are currently mapped, but you still want to replace them, use the window in the lower half of the dialog box. In the left-most window click on the field to replace and then click the Unmap button. This moves the field to the Unmapped window in the top half and you can now follow the previous steps to re-map it with a new field.

After you accept the mapping changes, the report is automatically updated so that all report fields and formulas have the old field name replaced with the new field name. This saves you the trouble of going back through a report and modifying all formulas that referenced that field. This is the same effect as using a program like MS Word and using the Search and Replace function.