Detecting Null Values

  • Thread starter Thread starter Mike C
  • Start date Start date
M

Mike C

I want to tell the form that when I click Save, if a
control does not have a value in it, to insert a value
before saving. For examples, use EMailAddress as the
name of the control (a text box), and 1 as the value to
be inserted if a value does not exist. I don't want to
just set 1 as the default value for the control.
 
Mike

Why? As in, "why do you want a meaningless value inserted if a meaningful
value isn't available?"

You don't HAVE to store anything, and putting something that MIGHT be
meaningful, but it requires special knowledge to be certain, is likely to
cause you more problems than it solves.

(sorry, the former statistics instructor came out...)

Good luck

Jeff Boyce
<Access MVP>
 
I need the value present later in other forms. Actually,
if anyone can give me the answer, I'll end up using it
later instead of in this form. In the meantime, I'm
interested in an answer, the reason is acedemic.
 
Mike

Sorry, I seem to be in a "why" mode...

I can understand using an email address entered in one form at some future
point, perhaps even in another form. But why would you need a "1" in a
later form? What will you or your users do with the "1"? You've described
"how" you are trying to do something, but not, in a technology-neutral way,
"what" you want to accomplish.

I ask because folks may be able to offer alternative approaches to "what"
you want to do.

More info, please...

Jeff Boyce
<Access MVP>
 
I'm simpply looking fir the code to complete an if
statement. If Me!EMailAddress = "Null" Then
DoCmd.Openform "EMailAddressWarningForm", acnormal.

If I knew what actually will work where "Null" is, I
wouldn't put in the false value in the earlier, input
form. The form that would contain code has a button for
the user to push that sends an EMail to them containing
the task assigned to them. At this point, the
EMailAddress is transparent to them. THey simply pick an
office title from a combo box. However, there are going
to be some Office Titles without EMail Addresses. I need
the form to know this and display the warning form that
there is no EMail address available, and stop the sending
process. I can "work around" it by assigning a default
value in the first place, "1", and use it in the If
statement, but then it shows up in the EMail text box in
the input form. I want to clean that up.

So, what goes in the If statement that will recognize
that there is no value? I could use it in many places.
My usual gurus say that Access has a problem and doesn't
recognize Null values very well.

Anybody know the answer?
 
Mike

A couple approaches:

If you are working in code behind the form, you can use the "If ... Then"
construction -- in a query, you'd need to use the Immediate If (IIF()
function).

One way to test is:

If IsNull([YourField]) = True Then
...

Another would be:

If Nz([YourField],"") = "" Then
...

Note that this second approach allows you to test for both null and
zero-length string.

Good luck! (and thanks for the patience)

Jeff Boyce
<Access MVP>
 
Back
Top