Link to home
Create AccountLog in
Avatar of cwbarrett

asked on

Table Field Default to ZLS

Is it a bad idea to set all fields, where possible, in a table to default to a ZLS by placing "" in the field's default value when creating a table?  I have been working with databases since dBaseII in the '80s and my applications are for in-house use, never to be sold, and not huge file sizes, over a local domain, not clout based, no SQL server.  And, I don't want to create complicated VBA to create an SQL that will ignore Nulls, I get by with some VBA but I'm no expert.  When I filter by form (sometimes multiple field filters) and I place text in the "filter" text box & requery/refresh in an "OnExit" event, I do not want records with null values for that field to show in the dataset.

My last application included filter-by-form fields that proved to be very difficult due to Null values in the table fields.  I was pulling my hair out trying to not show null values for a particular filter field.  I don't use the "Form Filter" in the form itself, I find this to be troubling and unstable.  I use criteria in the underlying query matched to filter fields in the form header.

What I also find troubling is that fact that when I have a record field with text and I delete all text within the field the value is a ZLS, not Null.

Can anyone give me a valid reason why I shouldn't completely eliminate Null values and force ZLS by default in my table(s) based on above?

Help is appreciated.
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

<<Is it a bad idea to set all fields, where possible, in a table to default to a ZLS by placing "" in the field's default value when creating a table?  >>

 It's not "bad" and it's not "good" either; it depends on what you want to achieve.

Some dislike having nulls anywhere, so they set all fields.  That's a valid approach and there's no real downsides other than making a mistake and not filling a field, at which point your app doesn't handle it well because you didn't account for nulls.

But Nulls do indicate something different than a ZLS.  A "null" means value unknown.   A ZLS is a value.

For example, a middle name.   Null means we don't know if there is one or not, but a ZLS means we do know that the person does not have one.

Avatar of cwbarrett


Thanks Jim, good info.  A week ago I did some testing and came to the conclusion that entering text into a field, saving the record, then returning to the same field/record and deleting the text would result in a ZLS, not null.  But I tried it again today with different results, manually deleting text results in a null.   So now I have to reevaluate the whole ZLS thing.

Seems to me that Access used to have the option "Allow Null Values" in table setup, but I don't see it now.

Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I'll plan on building an SQL to redefine the WHERE after I change one of the four "filter-by-form" fields in my form.  I'll use the iff() function to see if the form's search criteria is null.  SQL WHERE criteria will change from   Like "*" & [Forms]![frmLeadsList]![txtAddress1Filter] & "*"   to   Like "*" & [Forms]![frmLeadsList]![txtAddress1Filter] & "*" or is null  depending on whether the filter text box has text or not.

I'm not great at VBA so it'll take time for me to figure out.  What's interesting is if I open the form and do a filter by form it shows nulls.  But if I open the query directly with the same criteria and of course the form is open, the direct query run doesn't show the nulls.
I think you should have split the points with Jim ...  who gave equally valid input.
Thanks for pointing that out Joe.  Sorry Jim, sometimes I click w/o thinking.  Can I change?  If there is a way to change I will.
No worries...never been in it for the points and Joe's comment points out to future readers  that they  should consider the points I made .