mobile databases, mobile forms, and mobile synchronization … where you need to work
Providing Pocket Access, Mobile Database, Windows CE Database, and Windows CE Development Solutions

Tip of the Month (May 2007)

Updating Values in a Grid Control

A Grid Control is a great way for a form to show data from mulitple records all at the same time. But, you may want to let your user not only see the data, but also easily update it.

For example, say you have a PEOPLE table (with the columns PERSON_ID, NAME, and ADDRESS). On a form over the PEOPLE table you may want a grid that shows the NAME and ADDRESS of all the people, plus a quick way for the user change the NAME and/or ADDRESS of a selected person.

Here's how to do it:

  1. Select FILE | NEW FORM and create a new form over the PEOPLE table. When asked if you want the Visual CE form wizard to create a form. say NO.
  2. Select FILE | MODIFY TABLE, click YES to the warning, and make sure there is an index over PERSON_ID. If there is not an index over PERSON_ID, click ADD INDEX and create one. Click OK to close the "Modify Table" dialog.
  3. Create a macro (EDIT | MACRO/EVENTS) called SELECT_PERSON. The macro will have three steps in it:
      Command 1: SORT BY - PERSON_ID as the column to sort on
      Command 2: RECORD | SEARCH - "Exact matches only" on, @var(34) as the argument
      Command 3: RETURN FROM MACRO
    Click CLOSE to close the macro editor.
  4. Create the grid control on the form. When asked for the search key, select "Show all records". Click ADD AFTER to add the NAME and ADDRESS columns to the grid.
  5. On the right hand side of the grid properties, you will see "Set...to current...". Set this to "Set @VAR(34) to current PERSON_ID".
  6. Click the EVENTS button and set the CHANGED event to SELECT_PERSON. Click OK.
  7. Click OK to close the grid properties.
  8. On your form, add an edit control connected to NAME and an edit control connected to ADDRESS.

When this form is run on the handheld, the user can tap on an entry on the grid control, the form will move to that record, and then the user can use the edit controls to change the values for the selected entry.