English

How To: Convert a number field to a string field

Summary

Steps to convert a number field to a string field.

Procedure

  1. Add a string field to the table.
    1. Open the table and Start Editing, if necessary.
    2. Select Add Field from the Edit menu.
    3. In the Field Definition dialog box, define the following:
      a) Set Name to an appropriate name, for example 'Name'.
      b) Set Type to String.
      c) Set Width to an appropriate number, for example '32'.
    4. Click OK.
    5. Select Stop Editing from the Table menu and save the edits.
  2. Use the Field Calculator to copy the values to the new field and convert the values to a string.
    1. Open the table and Start Editing, if necessary.
    2. Select the string field.
    3. Select Calculate from the Field menu.
    4. Double-click the number field from the Fields list.
    5. Set the Type to Number.
    6. Scroll down the Requests list and double click on AsString.
      The final expression should look similar to this:
      Code:
      [Num_field].AsString
    7. Click OK.
    8. Select Stop Editing from the Table menu and choose to save the edits.
    Note:
    To maintain decimal places, use the SetFormat request. For a number field with 4 decimal places the expression should look similar to the following:
    Code:
    [Num_field].SetFormat("d.dddd").AsString

    The number of decimals in the field determines what the SetFormat request should look like. For example, if there are 6 decimal places, the request parameter should be ("d.dddddd").

Related Information