RecordRef.Next([Integer]) Method

Version: Available or changed with runtime version 1.0.

Steps through a specified number of records and retrieves a record.

Syntax

[Steps := ]  RecordRef.Next([Steps: Integer])

Parameters

RecordRef
 Type: RecordRef
An instance of the RecordRef data type.

[Optional] Steps
 Type: Integer
Defines the direction of the search and how many records to step include. If this parameter is greater than zero, the method will search the number of records specified in Steps forward in the table. If this parameter is less than zero, the method will search the number of records specified in Steps backward in the table. If this parameter is 0, no records are stepped over. If you do not specify this parameter, the method finds the next record.

Return Value

[Optional] Steps
 Type: Integer
Defines the direction of the search and how many records to include.

Remarks

This method locates a record positioned a given number of steps forward or backward from the record specified by RecordRef. Movement through the table is governed by the filters and the current key associated with the records. The fields in the record which will be compared with the current key fields must contain appropriate values before the method is called.

This method works the same as the Next Method (Record).

Example

The following example opens the Customer table as a RecordRef object, creates a reference to the first (No.) field, and stores the reference in the MyFieldRef variable. The SetRange method sets a filter that selects all records from 10000 to 40000 in the No. field. The Find Method (RecordRef) searches and selects the first record in the filter and counts the number of records that are found. The number of records is stored in the Count variable. The process is repeated by looping through all the records in the filter until no more records are found. The Next method steps through the records and finds the next record because no value is specified for the Steps parameter. The number of records that are found in the range is stored in the Count variable and displayed in a message box.

var
    CustomerRecref: RecordRef;
    MyFieldRef: FieldRef;
    Count: Integer;
    Text000: Label '%1 records were retrieved.'; 
begin    
    CustomerRecref.Open(Database::Customer);  
    MyFieldRef := CustomerRecref.Field(1);  
    MyFieldRef.SetRange('10000' , '40000');  
    Count := 0;  
    if CustomerRecref.Find('-') then  
      repeat  
        Count := Count + 1;  
      until CustomerRecref.Next = 0;  
    Message(Text000 , Count);  
end;

See Also

RecordRef Data Type
Get Started with AL
Developing Extensions