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 (January 2002)

Running a Macro Program When a Form is First Launched

When a Visual CE form is first launched (either from the START menu, a Jump Button, or a Command Button) you may want the form to do something before the user gets control. For example, you may want to insert a new record every time the form is started.

Starting in Visual CE 10.0, all you need to do is use EDIT | MACRO/EVENTS to create a macro and then set the "On Startup" event to trigger that macro. When the form is launched, the macro will be run.

In Visual CE 9.x, all you need to do is create a named macro called "STARTUP". When the form is launched, this macro will be run.

If you have an older version of Visual CE, here is how to do it.

  1. Create a move-to-region Command Button whose move-to position is top = 0, left = 0. Turn on the "Initial position on startup" property.
  2. Create a second Command Button to do the operation you want to do (in our example RECORD | INSERT).
  3. Go back to the move-to-region Command Button and turn on the "Continue" property.

When the form is launched, Visual CE will initialize itself and then behave as if the first button was pressed. Since forms always come up at position top = 0, left = 0 the first button won't really do anything. But, since the continue flag is set, control will continue to the next button (which, in our example, will insert a new record).