Results 1 to 5 of 5
  1. #1
    tsvetkovdimitar is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2013
    Location
    Dublin, Ireland
    Posts
    29

    Need to use constraints

    I don't know if it's possible so my question may sound stupid. I am wondering if I can use constraints in column containing integer data type. The value should be


    not < 12 and not > 36 for instance. Is that possible? Thank you.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is that possible?
    Did you try anything? What were the results?

    If you mean a field in a table, then try putting "Not < 12 And Not > 36" in the Validation Rule property in the table design view.


    I don't use the Validation Rule property; instead, I prefer to use the form Before update event to validate values.

  3. #3
    tsvetkovdimitar is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2013
    Location
    Dublin, Ireland
    Posts
    29
    Thanks for your help. I tried that, the access said it's too complex, try simplifying by assigning values to the variables....

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    In a query, you could use constraints along this set up

    SELECT your fields
    FROM YourTable(s)
    WHERE intValue BETWEEN 12 AND 36

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I read you were trying to limit the values in a field by setting a validation rule in a table.
    I think I misunderstood what you were asking...

    orange has the correct answer.


    As an explanation, you understand what "not < 12 and not > 36" means.
    But the computer does not. You have to compare each part to a field. So if the integer field is named "intMyField", the computer needs

    WHERE intMyField Not < 12 AND intMyField Not >36

    Or you could write it:
    WHERE intMyField >11 AND intMyField < 37

    Or as orange provided:
    WHERE intMyField BETWEEN 12 AND 36


    But this will not work:
    WHERE intMyField Not < 12 AND Not >36

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

Similar Threads

  1. Query with multiple date range constraints.
    By younggunnaz69 in forum Queries
    Replies: 2
    Last Post: 12-26-2011, 10:45 AM
  2. Replies: 1
    Last Post: 11-07-2011, 11:42 AM

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