Results 1 to 2 of 2
  1. #1
    benLL is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Nov 2015
    Posts
    1

    Simple Validation question from newbie


    Hi,
    I am trying to set a Validation rule in Access 2013.
    I want to limit the data input as a number range to between 1 and 3.
    Every syntax I have tried comes up with (missing operator) in table level validation expression.
    It may be a simple answer, but its bugging me. Going through nicotine withdrawl does not help.
    Thanks in advance.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You can put a check constraint on a field using this sort of command in the immediate window.
    However, I have seen no simple way to know what constraints exist. So if you add such a constraint document it well.

    Here I am putting a check constraint (check this before adding a record to this table) to restrict InputRange to 1,2 or 3 on Table JPersons

    Code:
    CurrentProject.Connection.Execute "ALTER TABLE JPersons ADD CONSTRAINT chk_Range  CHECK (InputRange>=1 and InputRange <=3);"
    I used this code to Drop the constraint
    Code:
    CurrentProject.Connection.Execute "ALTER TABLE JPersons DROP CONSTRAINT chk_Range"
    Also, I just added the validation rule to the table as per the attached jpg.
    And an example of the validation error that results if you attempt to enter a value outside the permitted range.
    Attached Thumbnails Attached Thumbnails ValidationRule_Between1 and 3.jpg   validationErrorExample.jpg  

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-16-2015, 07:23 PM
  2. Simple Database - Giving this newbie trouble
    By broomulack in forum Database Design
    Replies: 14
    Last Post: 07-27-2015, 12:17 PM
  3. Simple problem. Newbie Question
    By thalor in forum Programming
    Replies: 9
    Last Post: 07-03-2014, 12:43 PM
  4. Simple problem from a newbie user
    By jimmy2x2x in forum Access
    Replies: 3
    Last Post: 10-23-2011, 04:36 PM
  5. Newbie, seems simple to lookup value?!
    By ayce123 in forum Queries
    Replies: 3
    Last Post: 03-13-2011, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums