# FieldRef.Value([Any]) Method
> Version: _Available or changed with runtime version 1.0._
Sets or gets the value of the field that is currently selected. This method returns an error if no field is selected.
## Syntax
```al
[Value := ]  FieldRef.Value([NewValue: Any])
```
> NOTE
> This method can be invoked using property access syntax.
## Parameters
FieldRef
Type: fieldref-data-type
An instance of the fieldref-data-type data type.
*[Optional] NewValue*
Type: ../any/any-data-type
## Return Value
*[Optional] Value*
Type: ../any/any-data-type
## Remarks
If you omit NewValue, the method returns the current value of the field.
If you want to format the value of a FieldRef you must use `Format(FieldRef)` instead of `Format(FieldRef.Value)`.
## Example
The following example opens table 18, the Customer table, a RecordRef variable that is named CustomerRecref. The ../recordref/recordref-field-method creates a FieldRef for the first field \(No.\). The reference to the field is stored in the MyFieldRef variable. The fieldref-active-method method determines whether the field is enabled. If the field is enabled, then the record that is identified by the number in the CustomerNo variable is selected. The MyFieldRef variable is updated to refer to the second field \(Name\). Then the value in the second field is changed to Contoso. The ../recordref/recordref-modify-method modifies the record in the table to reflect the change. MyFieldRef.Value retrieves the new name and displays it in message box.
```al
var
    MyFieldRef: FieldRef;
    CustomerRecref: RecordRef;
    CustomerNo: Code;
    Text000: Label 'Customer name has changed to %1.';
begin
    CustomerNo := '50000';
    CustomerRecref.Open(18);
    MyFieldRef := CustomerRecref.Field(1);
    if MyFieldRef.Active then begin
      MyFieldRef.Value(CustomerNo);
      MyFieldRef := CustomerRecref.Field(2);
      MyFieldRef.Value('Contoso');
      CustomerRecref.Modify;
      Message(Text000, MyFieldRef.Value);
    end;
end;
```
## Related information
fieldref-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/fieldref/fieldref-value-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/fieldref/fieldref-value-method/
