ACC2003/2007: Unbound Form>Class Module - Trapping Nulls and zerolength strings.

B

BacktoAccess

Looking for some input on best practices for dealing with unbound
forms for manipulating data through class modules. Specifically, I am
interested in the best practice for trapping nulls and empty strings.
My latest version casts all variables in the class as variants and
uses an Nz function prior to writing to the table. For Text fields, I
am changing nulls to empty strings and for numeric fields, I am
changing nulls to zeros.

I am aware of several different approaches to this problem but am
looking for some insight into what the "Best" solution is for this
scenario.

Thanks In Advance!
 
S

S.Clark

I think true database snobs believe that there shouldn't ever be a null or
blank value, such that there is a defaulted value for every field.

(e.g. -99=Unentered, 0=Opt not to answer, Positive integer = Other entered
value.)

If you followed that edict, then you'd never need to parse nulls or blanks.

I'm not a true database snob, so I just do what you've done.
 
B

BacktoAccess

I think true database snobs believe that there shouldn't ever be a null or
blank value, such that there is a defaulted value for every field.

(e.g. -99=Unentered, 0=Opt not to answer, Positive integer = Other entered
value.)

If you followed that edict, then you'd never need to parse nulls or blanks.  

I'm not a true database snob, so I just do what you've done.

Thanks for the input!

To clarify my line of questioning: I am mostly interested in some
different views on what point is best to deal with the dreaded null
value (or data validation in general). Can anyone think of any reason
that the handling of the null should be handled in the code of the
input/editing form itself?

My logic on putting it in the Class Module at the last possible moment
before writing/updating the table was that it centralized the logic.
In other words, I can use the same class module on a variety of forms
that are working with the data and I don't need to recode all of the
null checks.

I have in the past attempted to cast the private variables and
Property statements in the Class Module but had found that this forces
me to validate the data at the form level as well so I have leaned
towards leaving the Private variables and Property statement as
Variants.

Any other input on this will be appreciated as coding a lot of data
manipulation class modules is definitely in my future.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top