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

Macros and Events

Visual CE software allows you to build custom mobile database applications for any Windows Mobile, Pocket PC, Smartphone, or Windows CE device

Visual CE® Personal and Professional Editions Editions have a Macro Programming capability.

A Macro Program is defined as a sequence of commands that are executed, one at a time. Macro Programs are invoked when (a) the user clicks a button on the form, or (b) an event occurs (such as a value changed or a control gets or loses focus), or (c) the user selects an item on a custom menu.

Each command step in a macro can do one of many things:

Menu Command
Performs a menu command from within a macro program. Any menu command can be handled this way.

Run External
Starts some other Windows CE application. A value from the current record can be sent as a command line parameter.

Report CE®
Launches Report CE and generates a report about the record currently being shown by Visual CE.

Move to Region
Forms can be larger than the physical screen on the device. This allows you to move from one region of the form to another.

Launches another Visual CE form and positions to a related record in that form.

Puts up a message box on the screen with a message you specify, plays a system sound, or plays a pre-recorded sound.

Assigns a value to a column or global variable. The value can be an expression (the same type of expression that you specify in a calculated control).

Skips forwards or backwards in the Macro Program. You specify a specific place in the macro to go to. Alternatively, you specify the number of commands you want to skip (positive values skip forward, negative values skip backwards) as an expression (the same type of expression that you specify in a calculated control). An if...then...else can be used to control where to skip to (the condition can depend on the current values in the record).

Reads a NMEA GPS signal into a column of the table or a global variable.

Serial I/O
Allows to open a serial port, read and/or write characters to it, and close the serial port.

File I/O
Allows to open a text file, read and/or write characters to it, and close the text file.

Turns an mEnable connection on or off, synchronize the handheld over a wireless network, or get/put files on the mEnable server.

Import/Export of text files or XML files.

Delays the execution of a Macro Program for a specified number of seconds.

Change sort/search order
Changes the order of the records in the database.

Set Alarm
Sets an alarm to launch a form at a later date/time.

Set Timer
Sets n timer to run a macro at a later date/time.

Sends an SMS text message or opens a form when an SMS message is received.

Run a sub-macro
Run another macro and then continue with this one.

Show/Hide control
Show or hide a control.

Set focus
Set focus on a control.

Dial a phone.

Control the selected line in a grid.

Message Box
Display a message box.

Select Tab
Control the tab that is selected.

Things you can do with Macro Programming:

  • If you are building a questionaire, you can have a button that sets a checkmark (for example, gender) and then moves to the next appropriate set of questions.
Assign "Male" to Gender
Move to region with "Male" questions
Return from macro
  • You can add integrity constraints: test to make sure a value is in range and if not, display an error:
       Skip button: if age >= 0 go to Continue
       Put up an error message
       Return from macro
       Save the record
       Return from macro
  • You can add an event to a dropdown that gets triggred when the value in the dropdown changes. If you have a "Gender" dropdown, this could be used to hide/show a "Pregnant?" checkbox:
Skip button: if Gender = 'Male' then 2 else 0
Show "Pregnant?" checkbox
Return from macro
Hide "Pregnant?" checkbox
Return from macro


Bear in mind that this is a macro capability that is running on a handheld device. If you need to do significant record processing, it would be better to do this using some other tool on the desktop.

Macro Debugger

Visual CE includes a macro debugger. The macro debugger will allow you to see, on the desktop, the steps of a macro running on the handheld. The debugger will let you stop the macro while it is running; view the macro steps, column values, or variables; and then start the macro running again.


Events are generally (but not always) actions initiated by the user. You can associate a macro with ane vent, so that when the event occurs, the macro runs automatically.

Visual CE supports the following events:

A control gets/loses input focus.

The value in a control was changed by the user.

Up / Down / Left / Right
The user pressed the up/down/left/right button.

The user pressed the "action" button.

Hardware Button
The user pressed a hardware button.

Record Display
The form is moved to a record.

Leave Record
The form is moved from a record.

The form is starting.

The screen is rotating.

Select Tab
The selected tab has changed.