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!

Forms and required values

Status
Not open for further replies.

blackte

Programmer
Jul 24, 2001
80
US
I have form that has many fields on it that are enterable. I have set the database record to require most of the fields on the record. I have a issue that I would like to require about half of the fields when on field is set to a 'Y', and when the it's not set to a 'Y' then require all of the fields. Is there an easy way to do this, without a lot of coding or not. Thanks in advance for any help with this. Thanks Travis.
 
In the table, you should only set Required to Yes for fields that are always required, in every record.

For fields that are sometimes required, you may be able to use the Validation Rule property of the Table, but this would be difficult to set up if there are many such fields.

An easier method would be to ensure that records can only be entered via a form, and use code in the form module to enforce the requirements. This would still require a lot of code, but it would be easier to read and maintain. You would put this code in the form's BeforeUpdate event. It should check all the controls that are always required first, and then check for the "Y" flag, and if it's set then check the rest of the required controls. If any required controls are Null, display a message to the user (with MsgBox) and set the Cancel parameter to True. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top