Exercise 2: Creating custom Edit and Query forms
Creating a custom data entry form with data validation for an AXF layer
Next, you will create a layer definition file for the Poles layer. Layer definition files provide a way of delivering customizations loaded with the data in ArcPad.
This exercise introduces the basic techniques for creating custom forms to perform initialization and data validation for ArcPad Exchange Files (AXF). You will see that there is very little work done in ArcPad Studio and that data validation is initiated in the geodatabase. For this exercise, you need to create an AXF file in ArcMap.
Creating an AXF file using ArcPad Data Manager in ArcMap
You will start by checking out data from a geodatabase. For full guidance on how to check out data, refer to the ArcPad Help. The following demonstrates the minimum steps:
- Start ArcMap and open C:\Documents and Settings\All Users\Documents\ArcPad\Samples\Riverside\Riverside.mxd (on computers running Windows Vista or Windows 7, the sample data is installed under Public Documents). See the following screen shot:
- Click the Get Data For ArcPad button on the ArcPad Data Manager toolbar. The Get Data For ArcPad - Select Data dialog box appears.
- Click the arrow under the Action column for the Poles layer. Several action options appear. Select Check Out for disconnected editing in ArcPad, then Data based on defined extent. See the following screen shot:
- Select Export as background data (to shapefile), then Make Read only for the Streets layer.
- Click Next. The Get Data For ArcPad - Select Picture Options dialog box appears.
- Click Next. Type Poles as the AXF folder (and subsequently, file name) and map name. Save it to a designated folder.
- Click Next. The Get Data For ArcPad - Select Output Options dialog box appears. See the following screen shot:
- Click Next. The Get Data For ArcPad - Select Deployment Options dialog box appears.
- Select the Create the ArcPad data on this computer now radio button.
- Click Finish. A new AXF file is created.
If no AXF file is visible in the output folder, follow the Get Data for ArcPad wizard again and ensure that you selected Check Out for disconnected editing in ArcPad for the Poles layer. Also, confirm no errors are reported in the summary dialog box at the end of the wizard.
- Review the contents of the new Poles folder, which contains Riverside_mdb.axf and the Streets shapefiles. See the following screen shot:
Creating an Edit form for the Poles layer
The checkout tool automatically creates an Edit form for each layer inside an AXF file during the checkout process. The following steps show how to create an Edit form from scratch. Normally, it is easiest to start with the Edit forms created during the checkout process and modify them to suit your needs.This section demonstrates how you can create a new Edit form.
- Start ArcPad Studio and open the Riverside_mdb.axf file.
- Right-click the Poles feature layer and click Edit Layer Definition. The Layer Definition window appears. See the following screen shot:
- Click the Forms button on the toolbar. The Forms dialog box appears. Forms created during checkout are listed. In the following screen shot, an Edit form and a Query form shows:
- Before creating a new Edit form, you must first delete the existing Edit form. Select the Edit form from the list and click Delete.
- To create a new Edit form for the Poles layer, click the EDITFORM button on the Forms dialog box. An Edit form dialog box appears with the Controls and Fields palettes. The Fields palette is a collection of smart controls for all the Poles layer fields. Each smart control has the associated field name listed next to it. See the following screen shots:
- Click the Form menu and click Form Properties. The Form Properties dialog box appears.
- Use this dialog box to make changes to the form's properties. For example, if you do not want all pages to be visible, clear the Symbology Page and Attributes Page check boxes. Type Poles in the Caption text box. Click OK. Notice, the caption changes to Poles. See the following screen shot:
- Click the Label control button on the Controls palette and drag it to the Edit form.
- The Control Properties dialog box for the Label control is visible after you drop the control on the page. Type lblPOLEID in the Name text box and Pole ID in the Caption text box. You can resize and change the placement of a control manually in the form editor or by changing properties on the Control Properties dialog box. See the following screen shot:
- Type 30 in the Width text box and 12 in the Height text box to change the width and height properties. For the X and Y placement options, you will manually align the controls with the existing controls on the page.
- Click OK to close the Control Properties dialog box.
- Click and drag the POLEID Edit control from the Fields palette to the page of your Edit form. See the following screen shots:
- Double-click the POLEID Edit control. The Control Properties dialog box appears. Type edbPOLEID in the Name text box. Type 80 in the Width text box and 12 in the Height text box. Notice, this Edit control is already associated to the POLEID field; therefore, there is no need to change the Field text box.
- Click OK to close the Control Properties dialog box. Click and drag another label control to the Edit form.
- Type lblINSTALLDATE in the Name text box and type INSTALL DATE in the Caption text box.
- Type 60 in the Width text box and 12 in the Height text box. See the following screen shot:
- Click OK.
- Click and drag the INSTALLDATE control from the Fields palette to the Edit form. See the following screen shot:
- Type dtpINSTALLDATE in the Name text box. Type 80 in the Width text box and 14 in the Height text box. You'll manually align the position of the control on the form; therefore, leave the X and Y position as is. See the following screen shot:
- The last field you want to add to the Edit form is the Material field. Drag and drop a Label control to the Edit form.
- Type lblMaterial in the Name text box and Material in the Caption text box.
- Type 30 in the Width text box and 12 in the Height text box. See the following screen shot:
- Click OK to close the dialog box.
- Click and drag the Material DomainField control from the Fields palette to the form.Note:
Coded value domains (CVD) are used to enforce data integrity for the Material and Manufacturer fields in the source geodatabase (Riverside.mdb). These CVDs are acknowledged during the ArcPad checkout, stored in the AXF, and bound to their associated fields. The field controls for the Material and Manufacturer fields are called DomainField controls. DomainField controls show as combo boxes with predefined values. While editing a field with a DomainField control in ArcPad, you can only choose values from a selection list.
- Type dmfMaterial in the Name text box. Type 80 in the Width text box and 14 in the Height text box. See the following screen shot:
- Click OK to close the dialog box. Manually align the controls on the page.
Modifying the form's pages
- Click the Page menu and click Page Properties. The Page Properties dialog box appears. This dialog box is used to gather information about poles.
- Type Pole Information in the Caption text box. See the following screen shot:
- Click OK to close the dialog box. The Poles form resembles the following screen shot:
- Click OK to close the form and click OK to close the Forms dialog box.
- Click the Save button on the toolbar to save the form's layer definition.
Creating a custom Query form for the Poles layer
The Poles Query form helps field personnel to find poles installed on a specific date or within a specific time frame. You will create a Query form similar to the following screen shot:
- Double-click the <FORMS> element in the tree view of the layer definition. The following screen shot shows the tree view:
- When the forms wizard opens, click the QUERYFORM button. A new Query form appears.
- Click the Form menu and click Form Properties. The Form Properties dialog box appears.
- Type Find Poles in the Caption text box. Type 100 in the Height text box. Leave the default Width as 130.
- Clear the Page Tabs check box if you are creating a single page Query form. See the following screen shot:
- Click OK.
- Drag a Label control from the Controls palette to your Query form. The Control Properties dialog box appears when you drop the control on the form.
- Type Select Poles installed between in the Caption text box. Type 100 in the Width text box and 12 in the Height text box. See the following screen shot:
- Click OK.
- Drag the INSTALLDATE DateTime control from the Fields palette, then drop it on the form. See the following screen shot:
- Double-click on the DateTime control. The Control Properties dialog box appears.
- A Query tab is added to the Control Properties for the Query form. Click the Query tab and choose the >= Value Operator option. See the following screen shot:
- Click OK.
- Add another Label control to the Query form. The Control Properties dialog box appears when you drop the control on the form.
- Type and in the Caption text box. Type 30 in the Width text box and 12 in the Height text box.
- Click OK to close the Control Properties dialog box. See the following screen shot:
- Add another INSTALLDATE DateTime control to the form, double-click the second DateTime control.
- Choose the <= Value Operator option for this control. See the following screen shot:
- Click OK. Manually align the controls on the form. See the following screen shot of the created Query form:
- Click OK to close the Query form and click OK to close the form dialog box. Save your changes before closing the layer definition tree view window.
Changing the Poles layer icon
- Right-click the Poles feature layer in the AXF tree view window. Choose Set Layer Icon. See the following screen shot:
- Navigate to the sample Layer Icons folder. On Windows XP this is usually C:\Documents and Settings\All Users\Documents\ArcPad\Samples\Layer Icons, on Windows 7 this is usually C:\Users\Public\Documents\ArcPad\Samples\Layer Icons. Choose Street_Light.ico. See the following screen shot:
- Click Open. The Poles layer icon is automatically added to the tree view. See the following screen shot:
- Close the tree view window.