Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011

    Unanswered: Validation rule that restricts entry if another field Is Not Null or = 0

    I have begun desiging a database for my company that stores information about parts we produce for our customers. I am relatively new to Access.

    Sometimes customers parts have dimensions given in inches, while other times they are given in millimeters. I would rather have a query do the conversion to inches than the person doing it prior to inputting data.

    Here is how I was planning on handling this:

    I have a table with the following fields:
    Part Number

    When the query is ran, I use an Iif to see whether MM was inputted and if the user inputted in MM, it creates a new field that converts to inches.

    However, here is where I need help. I would like a validation rule to only allow Thickness(In) or Thickness(MM) to be inputted. For instance, if the user inputs a value for Thickness(In), I would like Access to prevent the user from inputting Thickness(MM) (unless Thickness(In) is null or =0).

    How can I accomplish this?

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    Try something like:
    Me.Thickness(MM).Locked = IIF Nz(Me.[Thickness(In)].Value, "") <> "", True, False)
    Me.Thickness(In).Locked = IIF Nz(Me.[Thickness(MM)].Value, "") <> "", True, False)
    Replacing [Thickness(MM)] and [Thickness(In)] by the names of the corresponding controls in your form. This could be included in a function that you would call from the AfterUpdate event of both textboxes.
    Have a nice day!

Posting Permissions

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