Working with databases
Lesson 7: Data Entry Objects
After learning how to access data from within DataFlex code the next step is to create a data entry view.
- Create a new project…
- From within the DataFlex Studio select the ‘Create New’ icon from the top toolbar.
![](/ContentData/1178-WorkingWithDBsL7_1_new.png)
- Select the ‘Project’ tab.
- Select ‘Windows Project.’ Select OK.
![](/ContentData/1179-WorkingWithDBsL7_2_project.png)
- Enter “Cookbook” as the ‘File Name.’ Select OK.
![](/ContentData/1180-WorkingWithDBsL7_3_cookbook.png)
- Creating a standard Windows Project automatically creates a view with the standard toolbar.
![](/ContentData/1181-WorkingWithDBsL7_4_toolbars.png)
- Create a view…
- Select the ‘Create New’ icon from the top toolbar.
- Select ‘Data Entry View.’ Select OK.
![](/ContentData/1182-WorkingWithDBsL7_5_dataEntry.png)
- Enter “oRecipe” as the ‘Object Name.’ Select OK.
![](/ContentData/1183-WorkingWithDBsL7_6_oRecipe.png)
- Use the DDO Explorer on the right to add objects…
- Select the ‘Add DDO’ icon from the top of the panel.
![](/ContentData/1184-WorkingWithDBsL7_7_addDDO.png)
- Select ‘cRecipeDataDictionary’ form the list. Select ‘Select.’
![](/ContentData/1185-WorkingWithDBsL7_8_RecipeDDO.png)
- Expand ‘DDO Column Selector’ in the DDO Explorer.
![](/ContentData/1186-WorkingWithDBsL7_9_expand.png)
- Expand ‘cRecipeDataDictionary [Main DDO]’ in the DDO Explorer.
- Check ‘Name’
![](/ContentData/1187-WorkingWithDBsL7_10_name.png)
- Click on ‘Name,’ and drag it into the ‘Recipe’ view.
![](/ContentData/1188-WorkingWithDBsL7_11_nameDrag.png)
- Adjust the width of the view as needed.
- Check ‘HowToMake,’ ‘PreparationTime,’ and ‘Created.’
![](/ContentData/1189-WorkingWithDBsL7_12_otherChecks.png)
- Click on ‘HowToMake,’ and drag it into the view. This will result in all three checked items being added to the view.
![](/ContentData/1190-WorkingWithDBsL7_13_drag2.png)
- Expand ‘ cKitchenDataDictinoary’ in the DDO Explorer.
- Check ‘Name’
![](/ContentData/1191-WorkingWithDBsL7_14_kitchenName.png)
- Click on ‘Name’ and drag it into the view.
![](/ContentData/1192-WorkingWithDBsL7_15_drag3.png)
- Adjust the layout…
- For the kitchen name, select its field in the view.
- Select ‘Properties’ from the bottom of the panel on the right.
- From the ‘Label’ section, change ‘Label’ from “Name:” to “Kitchen:”
![](/ContentData/1193-WorkingWithDBsL7_16_label.png)
- Move the locations of the ‘Preparation Time,’ ‘Created’ and ‘HowToMake’ fields.
![](/ContentData/1194-WorkingWithDBsL7_17_layout.png)
- To view what these changes made, press F7 to view the source view, ‘Recipe.vw.’
![](/ContentData/1195-WorkingWithDBsL7_18_recipeVW.png)
- Select the ‘Run’ icon from the top toolbar to launch the application.
![](/ContentData/1196-WorkingWithDBsL7_19_run.png)
- Select ‘View’ from the application’s top toolbar and select ‘Recipe’ to display the view that was just created.
![](/ContentData/1197-WorkingWithDBsL7_20_app.png)
- Click on the ‘Find’ toolbar icons to move through the recipes.
![](/ContentData/1198-WorkingWithDBsL7_21_recipeFind.png)
- To add a lookup to the view…
- This will demonstrate how Data Dictionaries automatically bind lookups to fields.
- Select the ‘Create New’ icon from the top toolbar.
- Select the ‘Dialog/Lookup’ tab.
- Select ‘Lookup Wizard.’ Select OK.
![](/ContentData/1200-WorkingWithDBsL7_22_lookupWiz.png)
- Select ‘Next.’ Click on ‘Kitchen – cKitchenDataDictionary.’ Select ‘Next’ twice more.
![](/ContentData/1201-WorkingWithDBsL7_23_kitchen.png)
- Double click on ‘Name’ from the panel on the left to add it to the panel on the right. Select ‘Next’ three more times, and then ‘Finish.’
![](/ContentData/1202-WorkingWithDBsL7_24_addKitchen.png)
![](/ContentData/1203-WorkingWithDBsL7_25_view.png)
- Select the ‘Run’ icon from the top toolbar to launch the application.
- Select ‘View’ from the application’s top toolbar and select ‘Recipe.’
- The view now shows a prompt button in the ‘Kitchen’ field that will launch the lookup just created.
![](/ContentData/1204-WorkingWithDBsL7_26_prompt.png)
- Return to the DataFlex Studio and select the ‘Recipe.vw [Design] tab.
- To add a rating field to the application…
- Select ‘View’ from the top menu and select ’Class Palette’ to open the palette in the left panel.
![](/ContentData/1205-WorkingWithDBsL7_27_classPalette.png)
- Expand ‘Data Controls.’
- Select, drag and drop ‘dbTrackbar’ onto the view.
![](/ContentData/1206-WorkingWithDBsL7_28_dataCont.png)
![](/ContentData/1207-WorkingWithDBsL7_29_drag.png)
- In the ‘Properties’ panel’s ‘Properties’ tab on the right set the ‘Label’ to “Rating:”
![](/ContentData/1208-WorkingWithDBsL7_30_label.png)
- In the ‘Properties’ panel’s ‘Binding’ tab on the right click on the prompt in the ‘Data Source (Entry_Item)’ field to open the ‘DDO Column Selection’ Window.
- Expand ‘oRecipe_DD,’ select ‘Rating,’ and click OK.
![](/ContentData/1209-WorkingWithDBsL7_31_rating.png)
![](/ContentData/1210-WorkingWithDBsL7_32_binding.png)
- Select the ‘Run’ icon from the top toolbar to launch the application.
- Select ‘View’ from the application’s top toolbar and select ‘Recipe.’
- Clicking on the ‘Find’ toolbar icons to move through the recipes will show movement on the newly created ‘Rating’ bar.
![](/ContentData/1211-WorkingWithDBsL7_33_results.png)
- To set the max value for the rating bar…
- Return to the DataFlex studio.
- Click on the ‘Properties’ tab in the ‘Properties’ panel on the right.
- Change the ‘Maximum_Position’ from “100” to “10.”
![](/ContentData/1212-WorkingWithDBsL7_34_maxChange.png)
- Select the ‘Run’ icon from the top toolbar to launch the application.
- Select ‘View’ from the application’s top toolbar and select ‘Recipe.’
- Clicking on the ‘Find’ toolbar icons to move through the recipes will show movement on the ‘Rating’ bar that has been adjusted with a lower maximum of 10.
![](/ContentData/1213-WorkingWithDBsL7_35_trackBar.png)
- Note: F7 and F8 are the shortcut keys for finding, or moving through, the records of the field that is highlighted.
- To show how the Data Dictionary objects are related to fields on the screen, and how finds can be performed to influence the current records being displayed…
- Return to the DataFlex studio, and ‘Recipe.vw [Design]’
- Select, drag and drop ‘Button’ from the ‘Class Palette’ on the left onto the view.
![](/ContentData/1214-WorkingWithDBsL7_36_button.png)
- Double click on the view to return to the code for the view.
- Add code for the button that will show how the data bound fields work together with the Data Dictionary…
Set Label to ‘Find the pickled cucumber’
//fires when the button is clicked
Procedure OnClick
Move “Pickled cucumber” to Recipe.Name
Send Find of oRecipe_DD GE 2
End_Procedure
![](/ContentData/1215-WorkingWithDBsL7_37_buttonCode.png)
- Select the ‘Run’ icon from the top toolbar to launch the application.
- Select ‘View’ from the application’s top toolbar and select ‘Recipe.’
- Click the new button to show the Pickled Cucumber recipe.
![](/ContentData/1216-WorkingWithDBsL7_38_results2.png)