Search code examples
validationviewinfopathoffice-2007

Infopath 2007 - How do I perform data validation on the current view ONLY?


I have an infopath 2007 form that I am developing which uses 3 different views.
The 3 different views are basically the same form, but have different text boxes shown, depending upon what button the user selects. I run into a problem where 'view 1' has some form validation, but the user has selected 'view 2' and submits it. The form validation on 'view 1' is triggered, and the user cannot submit the form. How can I ignore the form validation on 'view 1' if the user is currently submitting 'view 2'?


Solution

  • Rather than tick the standard "this field cannot be blank" checkbox (for example), you need to use the Data Validation rules instead. Lets say you have two views with a textbox in each that cannot be blank, but you want to only enforce the current view. Here's the structure of the form:

    fields:

    • currentView (number) (default = 1)
    • text1 (text) text2 (text)
    • button1
    • button2

    view 1 ( default)

    text1 - rule: if (currentView = 1 AND text1 is blank) show "cannot be blank"

    button1 - action: set a fields value (currentView = 2); switch views (to 2)

    view 2:

    text2 - rule: if (currentView = 2 AND text2 is blank) show "cannot be blank"

    button2 - action: set a fields value (currentView = 1); switch views (to 1)

    Make sense?

    Oisin