This discussion is archived
6 Replies Latest reply: Mar 4, 2013 9:30 AM by CraigB RSS

Validation on multiple fields

994029 Newbie
Currently Being Moderated
Hi,

I have a form, CUSTOMER , with various fields e.g. custid, fname, sname, address ...etc

When saving a new record I wish for it to check all of these fields to see if they are NULL or NOT NULL, if any one of these fields are NULL a error message will be displayed e.g. "data not entered" and if they are NOT NULL the record will be saved successfully.

Any help / point in the right direction would be greatly appreciated

Thanks,
DC
  • 1. Re: Validation on multiple fields
    CraigB Guru
    Currently Being Moderated
    I would suggest using the Pre-Insert and Pre-Update combination of triggers or the Key-Commit trigger. In these triggers you can check to see if any of the fields are NULL. However, if the fields are required, why not just set the Required property of each field to Yes. This ensures they can't leave the field without a value and the Commit process will automatically check required fields without having to write any code.

    Craig...
  • 2. Re: Validation on multiple fields
    994029 Newbie
    Currently Being Moderated
    Now I feel stupid!

    Thanks for the advice! But there is one problem with this, say for example I type in a field, click tab or the next field, then want to go back to that field, it will not let me - I gather this is because the field I am currently in is blank and does not have any data in it! Is there a way around this?

    Any help with the message appearing. When I successfully commit a record it displays it in the bottom left hand corner and I want this to be displayed in a message box for the user to see clearly. Is it something along the lines of:-

    message('your message here');
    message('your message here');

    The above code would be used on the COMMIT button - WHEN BUTTON PRESSED trigger.

    Thanks,
    DC
  • 3. Re: Validation on multiple fields
    CraigB Guru
    Currently Being Moderated
    You can defer enforcement of the Required property until validation of the record by setting the Module property Defer Required Enforcement to Yes. This allows you to navigate within the record - moving from Field to Field. If you attempt to leave the record, then the required field(s) will then be validated and any Item level When-Validate-Item trigger(s) will fire. This property defaults to No - so each item is validated imediately.

    Craig...
  • 4. Re: Validation on multiple fields
    994029 Newbie
    Currently Being Moderated
    Thanks for the help Craig. Sadly I have left the database, so will report back tomorrow.

    Again thanks for the help!
  • 5. Re: Validation on multiple fields
    994029 Newbie
    Currently Being Moderated
    Hi Craig,
    It works just the way I wanted it to! Thanks for the solution
  • 6. Re: Validation on multiple fields
    CraigB Guru
    Currently Being Moderated
    Great! Glad I was able to help.

    Craig...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points