Record of records

How can i see on the from record of records

like this

1 of 50

2 of 50

etc

Can you rephrase that question ? it does not make any sense.

Please tell us:

  • What are you trying to achieve
  • What do you have to acieve the result

Or maybe (after reading this the 10th time or so):

If you intend to see the Index of a certain record within the total number of records displayed at a form:

This actually depends on the following considerations:

Do you want to show this information based on the currently selected filter or do you want an overall information?
Do you want to know the record index based on the currently selected key or based on the primary key?

To know the total number of records: Rec.COUNT returns the total number of records in this table (view as it could be filtered and therefore only shows the number of records in the filtered result set)

To find out the Index of the record is a lottle bit more tricky but can be done:

RecordIndex := 1
REPEAT
SkippedRecords := Rec.NEXT(-10000);
RecordIndex := RecordIndex + ABS(SkippedRecords);
UNTIL SkippedRecords <> -10000;

aftrer executing this code the “RecordIndex” variable contains the Index of the record (based on the current sorting).

I want to show this information based on an overall information on the form.

Yeap, still the same code:

MaxRecords := Rec2.COUNT;
RecordIndex := 1
Rec2.GET(Rec.PrimaryKeyField1) ; // include all primary key fields in this table
REPEAT
SkippedRecords := Rec2.NEXT(-10000);
RecordIndex := RecordIndex + ABS(SkippedRecords);
UNTIL SkippedRecords <> -10000;
ActualRecordText := STRSUBSTNO('%1 of %2', RecordIndex, MaxRecords);

Rec2 is a record variable with the same table as sub type.

You add this code to the “OnAfterGetRecord” trigger of the form and use the “ActualRecordText” variable as sourceExpression for a text box you place somewhere in the form.

Thanks Thomas