# RecordRef.Count() Method
> Version: _Available or changed with runtime version 1.0._
Counts the number of records that are in the filters that are currently applied to the table referred to by the RecordRef.
## Syntax
```al
Number :=   RecordRef.Count()
```
> NOTE
> This method can be invoked using property access syntax.
## Parameters
RecordRef
Type: recordref-data-type
An instance of the recordref-data-type data type.
## Return Value
Number
Type: ../integer/integer-data-type
The number of records in the table.
## Remarks
This method returns the number of records that meet the conditions of any filters associated with the records. If no filters are set, the method shows the total number of records in the table.
> NOTE
> The Count method does not lock the table before it retrieves the number of records in the table. This means that the method reads both uncommitted and committed data, which could cause the number of records that is returned to be inaccurate. To make sure that the count is accurate, use the recordref-locktable-method before you use the Count method.
In previous versions of Dynamics 365, the Count method ignored security filters and always returned the total number of records unless you called the SetPermissionFilter method to get a filtered count.
This method works just like the ../record/record-count-method.
## Example
The following example opens table number 18 \(Customer\) as a RecordRef that is named MyRecordRef. The recordref-locktable-method locks the table. The Count method then retrieves the number of records in the table. The number of records is stored in the Count variable. The name of the table and the number of records in the table is displayed in a message box. The varTableNo variable can be used to open any table and get the number of records in that table by changing the value of the varTableNo variable.
```al
var
    MyRecordRef: RecordRef;
    varTableNo: Integer;
    Count: Integer;
    Text000: Label 'The number of records in the %1 table is: %2.';
begin
    varTableNo := 18;
    MyRecordRef.Open(varTableNo);
    MyRecordRef.LockTable;
    Count := MyRecordRef.Count;
    Message(Text000, MyRecordRef.Name, Count);
end;
```
## Related information
recordref-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/recordref/recordref-count-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/recordref/recordref-count-method/
