Last updated: 27 Apr 2005 by XpertSS.com
(Including sequentially numbering a set of records and making global changes to a set of records)
This FAQ demonstrates macros implemented in Approach V3, 96 or 97 or any of the "Millennium Edition 9.x" releases. Macros were implemented differently in prior versions of Approach, so if you used version 1 or 2, you will need to spend some time in the help files / manual of Approach to accomplish a similar result.
Broadly speaking, a looping macro (which may consist of several individual macros working together) does the following:
SET db.phonenumber to If(Left(db.phonenumber,1)='5', Combine('6',
db.phonenumber),db.phonenumber)
(where "phonenumber" is a text field)
Often it is necessary to have a macro that precedes the looping macro to set up the conditions that the loop needs for its correct operation. (I'll call this a Control macro). This may do things such as:
To carry information from one record to the next you need to use variable fields. For instance, if you want to sequentially number a set of records you need to know what number the previous record was in order to set the number of the current record.
The following example demonstrates both the use of a Control Macro and a Variable to sequentially number a set of records:
1) Create a numeric field 'VarIDNumber' to hold the sequential number, and a variable field 'VarID' to use in calculating the sequential numbers.
2) Create a looping macro 'SequentialLoop'. This macro should do the following:
3) Create a macro 'Sequential numbering' to be the Control Macro. It should do the following:
Note: In V2.1 you need to use three macros (it does exactly the same things as shown above, but it just takes 3 macros to do it. In v2.1 it is easy to end up with loop macros containing several macros):
Macro 1:
Set the variable field to 1
Run Macro 2
Macro 2:
Set the numeric field to variable field
Menu Options: Next Record
Run Macro 3
Macro 3:
Set the variable field to variable field + 1
Run Macro 2
Also see 'Record numbering' in this FAQ.