JavaScript Editor js editor     Web development 

Main Page

You can set values in free and database table fields with Integer type to increment automatically.

Automatically incrementing field values is not supported for local, remote, or offline views. Activating automatically incrementing values in a field sets the field as read-only, and its values cannot be changed with an insert, update, or replace operation. For more information, see Autoincrementing Field Values in Tables.

To set automatically incrementing values in a field

  1. Open the table in the Table Designer.

  2. On the Fields tab, select the field you want.

  3. In the Type list, select Integer (AutoInc).

  4. In the AutoIncrement area, type a start value for Next Value and an increment value for Step.

  5. When you are finished, click OK.

    When you select the Integer (AutoInc) type for a field, the Default value box becomes unavailable. However, Visual FoxPro neither discards nor uses the default value. Any expressions in the Default value box remain when you change the field type to or from Integer (AutoInc). You can still use code such as DBGETPROP( ) to retrieve the default value for the field. If you want to use the value in the Default value box, you must first change the Integer (AutoInc) data type.

For more information, see Fields Tab, Table Designer.

To set automatically incrementing values in a field programmatically

  • When creating the table using the SQL CREATE TABLE command, include the AUTOINC clause.


  • To edit an existing table, open the table with the USE command and then use the SQL ALTER TABLE command with the AUTOINC clause.

For more information, see CREATE TABLE - SQL Command or ALTER TABLE - SQL Command.

See Also

JavaScript Editor js editor     Web development