Checking field value > 0

JAKAJAKA Member Posts: 18
Hello!

I want to make Weight a mandatory field and >0.

This works if I try to enter zero value:
Weight - OnValidate()

IF Weight = 0 THEN
  ERROR(Text50006);

But if I jus tab through the fields, this trigger doesn't fire and the record is saved without weight. Is there a simple solution for this?

Comments

  • ypnavypnav Member Posts: 4
    Hi Jaka,

    Have you tried to put your code on the OnAfterValidate trigger?
    This should normaly work.
  • BeliasBelias Member Posts: 2,998
    same code in the oninsert, too.
    if you have already some records wrongly inserted, you won't get any error for these records...you should check them with a report for example...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • JAKAJAKA Member Posts: 18
    Thank You for your suggestions but they don't seem to solve my problem. If I enter 0 in the field, this fires the Validate event and shows the correct message.(OK)

    But if I just tab through the fields and not try to edit the default 0.00 value in field Weight, the validate event never occurs(?) and no message is shown.(NOT OK)

    I'm trying is to ensure that the user doesn't forget to enter the value.
  • BeliasBelias Member Posts: 2,998
    this is true, but if you try to insert the record, you'll get an error...so you will never have records with 0 values...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • SavatageSavatage Member Posts: 7,142
    did you search the forum for mandatory fields
Sign In or Register to comment.