When you create a new local view, you create it through the VPME Data Builder.
Ø To create a new local view
1. Local Views Node: On the Data Builder List page select the Local Views node under the name of the database in which you want to create the view.
Tip: Local views based on the VPME system tables are contained in a VPME application's SDATA_V and SVPM_V databases. Do not add your own local or remote views to those databases. When we update VPME, we may need to make changes to the system views. If so, the VPME update would include new versions of the system view databases. The new system view databases would replace the old version that contained your views, which means that you would lose any views you added to the SDATA_V or SVPM_V databases.
2. New: Click the New button. VPME brings up the Visual FoxPro View Designer and displays the Add Table or View dialog.
3. View Designer: Use the View Designer to create the view.
Visual FoxPro View Designer
4. Add Table or View: Select the database that contains the tables and views on which you want to base your new view. Then, select those tables and views. Click Add for each table and view. Set join conditions using the Join Condition dialog when it appears. After adding the tables and views you want, click Close.
5. Select Fields: Using the Fields page at the bottom of the View Designer, move the fields you want to include in the view from the Available fields list to the Selected fields list.
Tip - First Field From Parent Table – Source Table: When you are creating a view from more than one table, the first field in the view should come from the main, or parent, table. VPME can then identify the "source table" of the view as the table containing the first field in the view. Identifying the source table of a view is necessary at various points in a VPME application. It is needed when determining the relationship between a view and another table, view or CursorAdapter.
Tip – Include Primary Keys: Include in the Selected fields list the primary key field for each table that you want to update using the view.
Tip – Add All>> Button: If you use the Add All button to select all of the available fields for the view, move a field in the Selected fields list. If you do not do that and later add a field to the view's source table, you will not be able to reopen the view in the View Designer.
6. Update Criteria: When you are using a local view to update a local table or when you want to test a local view that you are creating to be used with a matching remote view, you need to enter the Update Criteria in the View Designer.
· Key Field: Click the Update Criteria tab on the View Designer. The first thing you need to do is identify the primary key field for each table you want to update using the view. Click twice in the space underneath the key symbol to the left of each key field. A check mark should appear, and the Update All button should be enabled.
· Select Fields to Update: If you want to update all the fields in the Selected fields list, click the Update All button. A check mark will appear to the left of all the fields except the field(s) you selected as the key field(s). Click under the pencil symbol to the left of the primary key field(s) so that the primary key field(s) will be updated too.
If you do not want to update all the fields in the Selected fields list, select the fields you want to update by clicking under the pencil symbol to the left of each field.
· Send SQL Updates: Click the Send SQL Updates check box.
You have now set the Update Criteria, and the View Designer Update Criteria page should look like this:
7. View Filters: If the view you are creating (a) will be used as a child view on a One-To-Many or Related Pages form, (b) will be used as an Initial Selected Alias view on a Related Forms parent form, or (c) will be used with the SQL Find Form, you must set filters for the view using certain variables with specific names expected by VPM.
Tip & Instructions: The filters you must set are described in the next section View Filters. At this point, read the "View filters" section and set up the filters that you determine your view needs. Then, return to step 8 below to complete the creation and set up of your view.
8. Name View: Close the View Designer. Save the view and give it a name. Visual FoxPro will create the new view, and VPM Enterprise will add it to the Data Builder.
View Designer Field Properties: While you can enter Field Properties in the View Designer, we recommend that you enter the view field properties in the VPME Data Builder. In particular, set up field validation on the Integrity page in the Data Builder instead of in the View Designer. The Data Builder provides predefined field validation rules that make setting up field validation easier (see Setting Up Field Validation).
However, if you need to use Field Properties outside your VPM Enterprise application, you should enter them in the View Designer. Any Field Properties you enter when you first create the view will be imported into the Data Builder.
9. Required Indexes: Create index tag definitions using the Tags Edit page. See Defining Indexes for Views to learn how to create index tag definitions for views. You need to create index tag definitions for views to make related forms, one-to-many forms and related pages forms based on views work. You can also create index tag definitions for the Toolbar Order control.
Tip: You must create the indexes described in Required Indexes for Views.
After you create the required indexes go to step 10.
10. View Properties: Click a view’s Edit page in the Data Builder..
· Description: Enter a Description for the view.
See Setting View Properties for the details on using the Data Builder to set up view properties.
11. Primary Key: Identify the view’s primary key index tag. Expand the view’s item list and select the primary key index tag. Click the Edit page. Check the VPM Primary checkbox on the Edit page to designate the tag as the primary key index tag.
12. Update Field Info Utility: If the Data Builder Field Properties, Integrity, Code and Help settings for the view will be the same or substantially the same as those of the view’s associated tables, you can save yourself considerable set up time by letting VPM Enterprise copy the Field Properties, Integrity, Code and Help settings from the Data Builder records of the associated tables to the Data Builder records of the view. VPM Enterprise provides an Update Field Info utility that will copy the Data Builder entries you have already made for the fields in the associated tables to the Data Builder records of the view. For example, the Update Field Info utility will automatically copy Field Descriptions, Default values, validation settings, etc. from the Data Builder records of the associated tables to those of the view. The Update Field Info utility can obviously save you a lot of time. You will normally want to use it. See Update Field Info - Views.
To run the Update Field Info utility, select the new view on the List page, click the Edit page and then click the Update Field Info button. VPM Enterprise displays a message asking you to confirm that you want to update the field information for the view.
Select Yes to perform the update. After you make your selection, VPM Enterprise copies the Data Builder Field entries for a view’s associated tables to the Data Builder records of the view.
Tip – Fields Update Lock: If you have specific view fields that you do not want to be included in the update, you can “lock” them to prevent the Update Field Info utility from changing their properties. See Field View Update Lock Property.
13. Referential Integrity: If the view contains a foreign key matching the primary key of another table, view or CursorAdapter, select the field in the treeview list and click the Edit page. Click the Integrity page and set up Referential Integrity validation for the field(s) in the foreign key. VPM Enterprise uses your Referential Integrity validation setup to determine how tables and views are related to each other in an application. See Referential Integrity for the details.
14. Field Label & Grid Captions: For each view field that will appear on a form or report, select the Edit - Properties page and enter a descriptive label in the Description (Short) and Description (Long) text boxes. Enter the label you want in a grid header in the Description (Short) text box. Enter the descriptive label that you want to appear next to the field on a form in the Description (Long) text box.
Tip: If you run the Update Field Info utility, the Referential Integrity and Field Label and Grid Captions will be entered for the view if they were previously entered for the view’s associated tables.