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 (April 2004)

Preventing "Ghost" Records

Whenever a Visual CE form is running, it is positioned on a record. If, when the form comes up, there are no records in the table, Visual CE creates a new record (using the default values). While running a form, if you delete all the records in the table, Visual CE creates a new record (using the default values). Immediately after this record is created, the user may close the application. When this happens, a "ghost" record will be left in the table.

Here's how to avoid this problem:

Say one of your columns is called NAME with an empty string as the default value. In the edit control over the NAME column, set the minimum length to 1 (minimum length is one of the properties of the edit control).

If a record gets created and, without changing the value of NAME, the user tries to close the form, Visual CE will detect that NAME as too short. Visual CE will put up a message ("Value of NAME missing") and the user will be given the opportunity to delete the record. The only way the user can close the application is if they delete the record.

You can use this technique with:

  • An edit control over a text column (with a zero length default value and a non-zero minimum length)
  • An edit control over a numeric column (with a default outside the minimum/maximum range)
  • An edit control over a date column (with a default outside that minimum/maximum range)
  • An dropdown which has no default value and has the "Required" property
  • A set of radio buttons which has no default value and has the "Required" property

By the way, if you have a macro with either these two commands:

Command 1: OPTION | CLEAR
Command 2: RECORD | CLOSE

or these three commands:

Command 1: OPTION | CLEAR
Command 2: RUN EXTERNAL and the "command" designates a .VCE file
Command 3: RECORD | CLOSE

when the form closes, there will be no records in the table when the form closes.