To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Grids
Cancel

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.

  1. Create a new project…
  2. From within the DataFlex Studio select the ‘Create New’ icon from the top toolbar.

  3. Select the ‘Project’ tab.
  4. Select ‘Windows Project.’ Select OK.

  5. Enter “Cookbook” as the ‘File Name.’ Select OK.
  6. Creating a standard Windows Project automatically creates a view with the standard toolbar.
  7. Create a view…
  8. Select the ‘Create New’ icon from the top toolbar.
  9. Select ‘Data Entry View.’ Select OK.
  10. Enter “oRecipe” as the ‘Object Name.’ Select OK.
  11. Use the DDO Explorer on the right to add objects…
  12. Select the ‘Add DDO’ icon from the top of the panel.
  13. Select ‘cRecipeDataDictionary’ form the list. Select ‘Select.’
  14. Expand ‘DDO Column Selector’ in the DDO Explorer.
  15. Expand ‘cRecipeDataDictionary [Main DDO]’ in the DDO Explorer.
  16. Check ‘Name’
  17. Click on ‘Name,’ and drag it into the ‘Recipe’ view.
  18. Adjust the width of the view as needed.
  19. Check ‘HowToMake,’ ‘PreparationTime,’ and ‘Created.’
  20. Click on ‘HowToMake,’ and drag it into the view. This will result in all three checked items being added to the view.
  21. Expand ‘ cKitchenDataDictinoary’ in the DDO Explorer.
  22. Check ‘Name’
  23. Click on ‘Name’ and drag it into the view.
  24. Adjust the layout…
  25. For the kitchen name, select its field in the view.
  26. Select ‘Properties’ from the bottom of the panel on the right.
  27. From the ‘Label’ section, change ‘Label’ from “Name:” to “Kitchen:”
  28. Move the locations of the ‘Preparation Time,’ ‘Created’ and ‘HowToMake’ fields.
  29. To view what these changes made, press F7 to view the source view, ‘Recipe.vw.’
  30. Select the ‘Run’ icon from the top toolbar to launch the application.
  31. Select ‘View’ from the application’s top toolbar and select ‘Recipe’ to display the view that was just created.
  32. Click on the ‘Find’ toolbar icons to move through the recipes.
  33. To add a lookup to the view…
  34. This will demonstrate how Data Dictionaries automatically bind lookups to fields.
  35. Select the ‘Create New’ icon from the top toolbar.
  36. Select the ‘Dialog/Lookup’ tab.
  37. Select ‘Lookup Wizard.’ Select OK.
  38. Select ‘Next.’ Click on ‘Kitchen – cKitchenDataDictionary.’ Select ‘Next’ twice more.
  39. 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.’

  40. Select the ‘Run’ icon from the top toolbar to launch the application.
  41. Select ‘View’ from the application’s top toolbar and select ‘Recipe.’ 
  42. The view now shows a prompt button in the ‘Kitchen’ field that will launch the lookup just created.
  43. Return to the DataFlex Studio and select the ‘Recipe.vw [Design] tab.
  44. To add a rating field to the application…
  45. Select ‘View’ from the top menu and select ’Class Palette’ to open the palette in the left panel.
  46. Expand ‘Data Controls.’
  47. Select, drag and drop ‘dbTrackbar’ onto the view.

  48. In the ‘Properties’ panel’s ‘Properties’ tab on the right set the ‘Label’ to “Rating:”
  49. 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.
  50. Expand ‘oRecipe_DD,’ select ‘Rating,’ and click OK.

  51. Select the ‘Run’ icon from the top toolbar to launch the application.
  52. Select ‘View’ from the application’s top toolbar and select ‘Recipe.’ 
  53. Clicking on the ‘Find’ toolbar icons to move through the recipes will show movement on the newly created ‘Rating’ bar.
  54. To set the max value for the rating bar…
  55. Return to the DataFlex studio.
  56. Click on the ‘Properties’ tab in the ‘Properties’ panel on the right.
  57. Change the ‘Maximum_Position’ from “100” to “10.”
  58. Select the ‘Run’ icon from the top toolbar to launch the application.
  59. Select ‘View’ from the application’s top toolbar and select ‘Recipe.’ 
  60. 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.
  61. Note: F7 and F8 are the shortcut keys for finding, or moving through, the records of the field that is highlighted.
  62. 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…
  63. Return to the DataFlex studio, and ‘Recipe.vw [Design]’
  64. Select, drag and drop ‘Button’ from the ‘Class Palette’ on the left onto the view.
  65. Double click on the view to return to the code for the view.
  66. 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

  67. Select the ‘Run’ icon from the top toolbar to launch the application.
  68. Select ‘View’ from the application’s top toolbar and select ‘Recipe.’ 
  69. Click the new button to show the Pickled Cucumber recipe.