How do I add a Record Validation Rule using IIF Statements?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaimin
    New Member
    • May 2010
    • 1

    How do I add a Record Validation Rule using IIF Statements?

    Hi

    I have a table tracking when members attend meetings.

    Field 1 (Attended Meeting) = Yes/No type data type
    Field 2 (Did the Member do a Presentation?) = Yes/No data type
    Field 3 (Topic of Presentation) = Text data type

    So essentially if a member attends a meeting; they indicate whether they did a presentation at the meeting or not. If they did do a presentation, they specify the topic of the presentation.

    So I thought I'd add record validation rules to prevent:
    a) someone from saying no attendance at a meeting but then putting in that they did a presentation

    b) putting a presentation topic in when they answered NO to whether they did a presentation or not

    So I need record validation rules here and I thought I'd use IIF statements here since these are all conditional expressions.

    Is this is the best way and if so; what's the IIF statement to use?
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by zaimin
    Hi

    I have a table tracking when members attend meetings.

    Field 1 (Attended Meeting) = Yes/No type data type
    Field 2 (Did the Member do a Presentation?) = Yes/No data type
    Field 3 (Topic of Presentation) = Text data type

    So essentially if a member attends a meeting; they indicate whether they did a presentation at the meeting or not. If they did do a presentation, they specify the topic of the presentation.

    So I thought I'd add record validation rules to prevent:
    a) someone from saying no attendance at a meeting but then putting in that they did a presentation

    b) putting a presentation topic in when they answered NO to whether they did a presentation or not

    So I need record validation rules here and I thought I'd use IIF statements here since these are all conditional expressions.

    Is this is the best way and if so; what's the IIF statement to use?
    Considering in reality that all of your data should be entered using forms then If I were you I would create a query based on your table, create your form based on that query and then do all of your validation in your form controls and code behind the form.

    You will get more control over your environment this way. You can do it in your table if you wish, it is up to you, but doing it in your form code allows for all sorts of logic to be applied not just expressions for example.

    Code:
    IF Me!Field2="No" then
    
            IF not isnull(Me!Field3) then
               Me!Field3=Null
            End If
    
       Me!Field3.enabled=false
    
    End If


    if you have total control over your design environment ie the physical data that gets entered into your tables then this is the my preferred method

    Comment

    Working...