Validation rules, default values, input masks & sort orders - in the form or in the table?

GopherUK

Active Member
Joined
Jan 23, 2009
Messages
473
Hi folks,

Just wondering how the professional developers choose to do this? Should these be in the placed in the tables or in the forms? It would seem to be that tables should simply be properly constructed with the field types and relations and all of the above along with the lookups should be done in the form itself? Is that correct?

Thanks in advance,

Gopher.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I put default values and validations in the table, usually. I suppose you can liken this to "server side" vs. "client side" rules. It's simpler and universal. I would nevertheless still use redundant validation on the forms if I wanted the user experience to be gentler (i.e., using custom error messages and/or other tricks to streamline data entry). Default values, if set at the table level, you never need to worry about anymore.

Lookups, sort orders - yes, form level as this is merely "presentation".

ξ
 
Upvote 0
I assume, given that all data entry will be via forms, to just have default values in the table and validation rules in the form? Would make error handling a little cleaner?
 
Upvote 0
I do both. There's no one recipe here. I prefer table validations because they are universal and you "do it once don't need to think about it anymore". If a table was supposed to have one of three values in it, for instance ("P","S", or "I") then I'd do that in the table. My form would use a combobox with three values to choose from, limit to list. So I don't need to validate anything - the user can do no wrong. Dates are, at minimum, validated by the fact that you can't put anything but a date into a date field.

On the other hand, form validations are usually more user friendly, as you typically create your own more informative messages. And I like to create forms that simply encourage users to do the right thing - list boxes, comboboxes, default values, good labels that make clear what's required.

The simplest way to ensure data is all there is to make fields required at the table level and/or to supply default values - but i suspect it's rarely done. The messages are admittedly a bit unfriendly and probably leave users scratching their heads as to what's wrong - but you don't get blank fields.
 
Last edited:
Upvote 0
My validations are often very minimal but I am the primary user of most of my work. I usually validate the things that I know I screw up, and leave the rest to chance (I'm usually analysing data, not entering it).
 
Upvote 0
I think I am aiming for validation in forms as I think it's just easier to use the form for validation rather than deal with all the error messages from the table-level validations.
 
Upvote 0
I have now gotten to the point where I have removed all validation rules, validation texts and I am not even setting required fields to 'No' in the table and simply running a function that checks to make sure the required fields are NOT NULL then returns TRUE or FALSE. I am running these on cmdSave_Click and Form_BeforeUpdate.

Seems to make life a LOT easier.

Anything I should be aware of?
 
Upvote 0
You've probably thought about this enough for now ;) strictly speaking, it sounds like you *are* doing some form of form-level validation - that's not uncommon so probably all is well.
ξ
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top