You can get even more out of Foxfire! by creating data items when existing data items don’t retrieve the information you need. For example, suppose you wanted to create a data item that displayed the model and make of a car as one data item instead of two separate data items.
There are two types of data items:
- Real data items. These are actual fields in the database file created by an administrator or developer.
- Foxfire! data items. These are data items you create in Foxfire!. They will not affect your real data and are not useable anywhere outside of Foxfire! When you create a Foxfire! data item it is stored in the Foxfire! Data Dictionary.
You can only create data items from the Workbench window so we will go ahead and open a new report here. After each exercise you will cancel the Request and discard your changes. That way you are not actually creating a new Request, you are just using the Workbench to create new data items.
When you create a data item it will automatically be stored in the Foxfire! Data Dictionary. Your new data item will be available whenever you use Foxfire! but it will not affect your real data and it will not be useable anywhere outside of Foxfire!
In Lesson 8-A you will create a new data item. In Lesson 8-B you will combine two data items to make a single data item.
Lesson Goals: You are going to create a new data item called Cars Month of Sale.
To create the new data item:
- From the Request Manager, create a new Detail report named TEST (title Test Report).
- Click the Select Data Items tab.
- Click Create.
- Enter Cars Month of Sale as the Data Item Name.
- Enter Cars Month of Sale (Alpha) as the Description.
- Select Inventory from the Data Item Group drop-down box. (Data Item Groups make it easier to find data items if there are many data items in your data dictionary.)
- Click the Edit button next to the Expression box to open the Expression Editor.
- Click on Cars Date of Sale in the Choose Item list.
- On the right hand side there is a box that says Choose date function. Select Month name as the date function.
- Click Create.The Expression Preview will say “Month name of Cars Date of Sale.” This is what the expression is in plain language.
- Click OK.You will now be back to the Create New Data Item screen. The expression now says (CMONTH(CARS.SALEDT)), which is the actual expression used by Microsoft FoxPro.Column Header 1 will be empty and Column Header 2 will say Cars Month of Sale.
- Enter “Month” in Column Header 1.
- Enter “of Sale” in Column Header 2.
- Click on the center alignment icon to the right of Column Header 1. This causes the column headers to be centered
- Enter March in the box that says Sample. That will be the sample value displayed in the Design Preview window.
- Change the Column width to 9 since the largest month is 9 characters. This is what the new data item will look like for Cars Month of Sale.
- Click OK. The new data item, Cars Month of Sale, appears in the Selected Items List. Cars Month of Sale will also appear in the Choose From list for any other Requests you create or modify.
Combine Data Items
Lesson Goals: You are going to create a data item that combines Cars Make and Cars Model in a single data item.
To combine the data items into a single data item:
- Click Create.
- Enter Cars Make and Model as the Data Item Name.
- Enter Cars Make and Model as the Description. You must assign this item to a Data Item Group. Data Item Groups make it easier to find data items if there are many data items in your data dictionary.
- In the Data Item Group drop-down box, select Inventory.
- Click on the Edit button next to the Expression box to open the Expression Editor.
- Click on Cars Make in the Choose Item list in the left-hand side of the window.
- Select Remove trailing spaces from the Apply formatting drop-down box.
- Click Apply.
- Click Space.
- Click on Cars Model in the Choose Item list.
- Click Insert.
- Click OK. You will now be back to the Create New Data Item screen. The expression will be (Trim(CARS.MAKE))+” “+CARS.MODEL, which is the actual expression used by FoxPro.
- Enter “Make/” in Column Header 1.
- Enter “Model” in Column Header 2.
- Enter “Buick Century” in the box that says Sample. That will be the sample value displayed in the Design Preview window.
- Change the Column width to 25.
- Click OK. The new data item Cars Make and Model appear in the Selected Items List. Cars Make and Model will also appear on the Choose From list for any other Requests you create or modify.
- Click the Cancel icon on the Design Preview toolbar.
- Click No when asked if you want to save the changes you have made to this Request.