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 2005)

Handling "Record not found" When Jumping

A Jump Button can be used to jump from one record to another based on a value that is common to both records. If the "never create" property is selected and there is no corresponding records in the destination table, Visual CE puts up a "Record not found" error message. Instead of the "Record not found" error, you might want to do some error handling instead.

You can do this by putting a Lookup Control on your form and putting a Jump in a macro. Here's how...

Say you are jumping from a CUSTOMER record to an ORDER record keyed on CUSTOMER_ID. And say it is possible that you have a CUSTOMER with no ORDERs.

On your CUSTOMER form, first create a lookup control, that looks in the ORDER table, keyed on CUSTOMER_ID. When asked if you want to save the value found, say YES and put it into a variable (for example, @var(34)). When asked what column to retrieve, select CUSTOMER_ID. When this form runs, the lookup control will fire. If there is an ORDER for the current customer, the current CUSTOMER_ID will be in @var(34). Otherwise @var(34) will be blank.

The macro you would use to test the Lookup Control is:

Command 1: SKIP. Set "number" to: if @var(34) = '' then 1 else 0
Command 2: The original Jump Button
Command 3, 4, 5...: Whatever you want done if there is no corresponding ORDER.