Accessing Field Values with a Dataset's FieldByName Method
You can access the value of a field with a dataset FieldByName method. This method is useful when you know the name of the field you want to access, but do not have access to the underlying table at design time.
To use FieldByName, you must know the dataset and name of the field you want to access. You pass the name of the field as an argument to the method. To access or change the value of the field, convert the result with the appropriate field component conversion property, such as AsString or AsInteger. For example, the following statement assigns the value of the CustNo field in the Customers dataset to an edit control:
Edit2.Text := Customers.FieldByName('CustNo').AsString;
Edit2->Text = Customers->FieldByName("CustNo")->AsString;
Conversely, you can assign a value to a field:
Customers.Edit; Customers.FieldByName('CustNo').AsString := Edit2.Text; Customers.Post;
Customers->Edit(); Customers->FieldByName("CustNo")->AsString = Edit2->Text; Customers->Post();