Results 1 to 6 of 6

Thread: Setting MS Access Validation Rules

  1. #1
    Join Date
    Oct 2004
    Posts
    3,198
    Rep Power
    0

    Default Setting MS Access Validation Rules

    I want to set a validation rule that allows values in a specific field to limit the values entered in another (same table). For example, numbers in Field B must be within 10 of numbers in Field A. So if Field A has 40, the value of the corresponding Field B record must be 50 or less. So the validation text would popup and state "Field B value must not exceed 10 of Field A value".

    Hope it is understandable, thx in advance for input.

  2. #2
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    You need something like :

    Code:
    If B>A+10 Then
               Msgbox("B cannot be more than 10 greater than A")
    Else
              ********Insert other code here*********
    End If
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  3. #3
    Join Date
    Oct 2004
    Posts
    3,198
    Rep Power
    0

    Default

    Ramesh, is there an easier method other than using macros? For example, specifying validation rule as "[FieldB]<=[FieldA]+10". That's what i been trying to use but when saving i get error "The expression was typed incorrectly or too complex to be evaluated". This was done in table design view.

  4. #4
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    As far as I know this is not possible in the table/field validation rules. It is possible in code, but defining it in the original field setup is not possible.
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  5. #5
    Join Date
    Oct 2004
    Posts
    3,198
    Rep Power
    0

    Default

    Ok thanks. I don't have the file with me now but i'll try your suggestion later. Would you use the same expression builder to enter the codes or is there an alternate code input method?

  6. #6
    Join Date
    Oct 2004
    Posts
    3,198
    Rep Power
    0

    Default

    Ok, it's working now. I had to enter codes at table-level and not field-level. Thanks for the input Ramesh.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •