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 (December 2003)

Using a Value From the Current Record When Creating a New Record

When creating a new record, you might want to initialize a control to the value in the current record. How to do this depends on your form and what you are trying to do:

Option 1:

If you want to put the duplicated value into a Calculated Control, just use the @prev() function. For example, if you had a Calculated Control connected to the STARTING_BALANCE column, the expression could be @prev(ENDING_BALANCE). Make sure that the "Recalculate" property of the calculated control is turned off.

Option 2:

If you have a filter active and the filter has just a single condition like ORDER_NUMBER = 1234, Visual CE automatically fills in the ORDER_NUMBER with 1234 when a new record is created.

This is especially useful if you launched the form using a Jump Button. If you jumped based on ORDER_NUMBER and the Jump Button's properties has "Only show matches" checked, Visual CE automatically activates a filter with the condition ORDER_NUMBER = 1234.

Option 3:

If Option 1 and Option 2 don't work for you, you can duplicate values using a macro. Say you have a form with an DESCRIPTION and a DATE. When you create a new record, you want to the DESCRIPTION to default to the one in the current record, but you want the DATE to be NULL (and DATE's default value is NULL as defined in the control). If you only need to duplicate a few values, this macro will work:

Step 1: ASSIGN, Value = DESCRIPTION, Col = @var(0)
Step 3: ASSIGN, Value = @var(0), Col = DESCRIPTION

If you find you need to duplicate many values, this macro will work:

Step 2: ASSIGN, Value = '', Col = DATE