Limit Numeric Field To 5 Digis

  • I am tring to create a table via an SQL command (vs the create table wizzard). Is there a way to create a numeric field with a limit of 5 digits in access? I know with ANSI SQL it would be number(5) but with access that did not work I tried the below but it errors on the "zip" line


    Code
    create table employee
     (emp_id varchar(9) not null,
      last_Name varchar(20) not null,
      first_name varchar(20) not null,
      st_address varchar(30) not null,
      city varchar(20) not nnull,
      state char(2) not null,
      zip Integer(5) not null,
      date_hire date);



    The code below works but does not limit the "zip" field to 5 digits



    Code
    create table employee
     (emp_id varchar(9) not null,
      last_Name varchar(20) not null,
      first_name varchar(20) not null,
      st_address varchar(30) not null,
      city varchar(20) not nnull,
      state char(2) not null,
      zip Integer not null,
      date_hire date);



    Can this be done or does the limiting have to be done via validation code in a module etc? I know that if I made it a character field I can limit it but then ahve to deal with the possibility of letters .

  • Re: Limit Numeric Field To 5 Digis


    Hi


    I don't think it is possible to define the precision of an integer. I think your only choice is to use a different type of number and specify the precision you want ie (5,0).


    Cheers


    Rowan

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!