Avatar of cwbarrett
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.
Charlie
Microsoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
Jim Dettman (EE MVE)

<<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.

Jim.
cwbarrett

ASKER
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.

Charlie
ASKER CERTIFIED SOLUTION
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cwbarrett

ASKER
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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

I think you should have split the points with Jim ...  who gave equally valid input.
cwbarrett

ASKER
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.
Charlie
Jim Dettman (EE MVE)

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 .

Jim
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.