Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making entry into a field obligatory

Status
Not open for further replies.

australia3

Technical User
Nov 9, 2004
64
GB
How do I make data entry into a field obligatory? i.e. document won't save unless data is entered into a specific field and an error message appears. Any ideas?
 
If the field is editable, use the Validation Formula in the field code.
A Validation Formula is specifically designed to return either True or False. If False, the document does not save.

Be wary of putting code in the Validation section that is not designed to check if the document is to be saved. If your formula does something else, then it might not evaluate to True, which could prove difficult in debugging why the doc does not save.

To summarize : For an editable field,
* the Default formula is calculated once for a new document
* the Translation formula is calculated on each refresh and can change the value of the field
* the Validation formula is also calculated on each refresh, but is destined to check if the doc can be saved or not

The issue with the Validation formula is that, quite often, you only want to check it when the document is actually being saved. So, if you do not include an @if(@IsDocBeingSaved.. in it, you'll end up with the check being done for each doc refresh. That could prove annoying for the user quite quickly (as in "why does it continually tell me I can't save when I haven't tried to ?").

For displaying the message, you can use @Return in your Validation formula.

A complete formula could look like this :
Code:
@if([i]fieldname[/i]="" & @IsDocBeingSaved;@Return("Please include a date of reception");@true)

Hope this helps,

Pascal.
 
You can also use @Failure(<Errormsg>) to display the missing data in a box on field level, and @Success...

And I agree with Pascal in the use of @IsDocBeingSaved as one of the main check points for field level validation; Without this the use of the application easily becomes frustrating, specially in the cases some 'auto refresh' is activated on form level, or selection fields has the 'refresh when keyword change' activated...

Field level validation works fine with a few fields mandatory, but I normally write a validation code in the QuerySave event when there is more than 4-5 fields that needs verification. The users can easily be irritated of a lot of boxes popping up one at the time, I therefore run through all obligatory fields and present 1 box in the end when there are errors (and interrupt the save of course).

For a few fields (1-4) it's seldom worth the extra job of a common validation code...

Brgds,

TrooDOS
 
thanks for your help on this, what would the code look like if I only wanted this field to be obligatory when a different field has certain text in it?
 
Hint: fieldname does not necessarily designate the field the formula is in.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top