JavaScript Editor js editor     Web development 

Main Page

You can specify default values that fields in database tables contain when adding new records, regardless of how the data is entered. These default values remain until they are replaced with new values.

You can specify default values for fields of any data type except General fields.

You can also view the default value for the field.

To specify a default value for a field

  1. Open the database containing the table.

  2. Open the table in the Table Designer.

  3. On the Fields tab, select the field that you want.

  4. In the Default value box in the Field validation area, type the default value you want for the field.

    Enclose text in quotation marks ("") for character fields.

  5. Click OK.

For more information, see Fields Tab, Table Designer.

To specify a default value for a field programmatically

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


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

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

For example, suppose you want to your application to limit the amount of merchandise a new customer can order until you can complete a credit check and determine the amount of credit you want to extend to that customer. The following code creates a customer table with a maximum order amount field with a default value of 1000:

В Copy Code
CREATE TABLE Customer (Cust_ID C(6), Company C(40), Contact C(30), ;
   MaxOrdAmt Y(4) DEFAULT 1000)

If the table exists, you can add a default value for the field:

В Copy Code

To view the default value for a field in a database table

  • Use the DBGETPROP(В ) function to retrieve the value of the DefaultValue field property.

For more information, see DBGETPROP( ) Function.

See Also

JavaScript Editor js editor     Web development