Help with using ERROR in form design.

I am doing some error checking on the Purchase Line Subform # 54. Were using Dimensions and if it’s a G/L account we want to make sure they can only use certain account #'s and dimension #'s. The code works but when they put in a invalid value it closes the form after the ERROR message pops up.

Here is the code:

IF (Type = 1) AND // Only looking at G/L line items
(ShortcutDimCode[3] > ‘02’) AND // set the value range
(ShortcutDimCode[3] < ‘13’) AND
(“No.” < ‘6000’) THEN BEGIN // any account #'s less than 6000 are invalid

ERROR(‘G/L Account Invalid’);


I need to add something here so it doesn’t close the form after clicking OK on ERROR message.

Thanks in advance,


That is because the field validation code is on the form. If this code were in the field validation trigger of the table (where it belongs in my opinion) then the form would not close after the error.

By the way, instead of using the integer value for option types, you should use the text value instead. This will make the code much easier to read:

So instead of:

IF Type = 1

Use this:

IF Type = Type::“G/L Account”


The code should be written in Purchase Line Table as a function and called on appropriate field triggers.

Writing code in forms is not a good practice.

Thanks for the replies all.

Unfortunately the Dimension I’m testing for isn’t on the Purchase Line table so I can’t put it in the table. If you look at the record in the purchase line table it’s not on there but it shows up on the form.

Not sure how it ties into the Purchase Line table.


It belongs to Table 357 (Document Dimension)

Thanks Dhan,