Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

4.13 Using a Table to Populate the List of Values

Using a Table to Populate the List of Values

The drawback to populating tables manually is that you have to type in each entry yourself. If the list of values is going to be large then this could take a lot of effort. In addition, you have to be careful that you spell everything exactly and that there are no typographical errors. An easier way to enter values is to import the values from a database table. This saves you time by not having to do any typing and you don’t have to worry about making mistakes.

Populating a list of values from a database is done by selecting the database field that has the data you need and then selecting which entries to use. On the dialog box, look below the option where you select either Static or Dynamic and there are two dropdown lists labeled Value Field. Click on the dropdown list to see a list of all the tables and fields in the report’s data source. Find the table which has the data you need and then select the field to pull that data from.

If you are using a database field to populate the list of values, then the Description column can also be populated with a database field. Click on the Description Field dropdown list to do so. Then the Description Field dropdown list automatically becomes enabled. By default, this dropdown list is disabled until you select a field for populating the Values column. The reason for this is that if you aren’t going to use a database field for populating the Values column then you can’t do it for the Description column either.

When selecting the field for the Description column, make sure that it is a field that is in the same table as the field selected for the Values column. For example, if the Values column uses the ProductID field from the Product table, then the Description column, ProductName, should come from the Product table as well. If you select a field for the description that is in a different table, Crystal Reports will try to find a relationship between the two tables and guess the correct record for the description. This educated guess may or may not be what you expected.