Re: Perform Check on Data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



mattc66 via AccessMonster.com wrote:
I have an Order Form that I want to perform a check on the data when the user
selects a Check Box.

I had the following in the onClick Event of the check box. This doesn't work.
It blows by them and displays an empty message box.

Dim MyStr1 As String
Dim MyStr2 As String


If Me.fldName1.Value = Null Then
MyStr1 = "txtName1 is Empty"
End If

If Me.fldName2.Value = Null Then
MyStr2 = "txtName2 is Empty"
End If

'Message box warning that data is missing.

MsgBox "The following Feilds are blank." _
& vbCr & vbCr & MyStr1 & "" _
& vbCr & vbCr & MyStr4 & "", vbOK, "Missing Data"


You can not compare anythig to Null, not even another Null.
Think of Null as meaning Unknown and then analyze the
comparison X = Null. I.e. Is X the same as an Unknown
value? The answer is always Unknown.

In VBA, use the IsNull function:
If IsNull(Me.fldName1.Value) Then

In SQL (or a query criteria) and in control source
expressions, use this instead:
fldname Is Null
The IsNull function will work in Jet SQL and in control
source expressions, but it is not as efficient in these
contexts.

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: Perform Check on Data
    ... You can not compare anythig to Null, ... Is X the same as an Unknown ... In SQL and in control source ... source expressions, but it is not as efficient in these ...
    (microsoft.public.access.formscoding)
  • Re: Calculations based on time
    ... the text box is empty. ... Name: SunStartW1, Control Source: SunStartW1 ... Calculation text box at bottom of Day: ... format on a floating point number not a date/time value. ...
    (microsoft.public.access.modulesdaovba)
  • Re: So whats null then if its not nothing?
    ... So it's neither unknown, nor empty. ... No. Check the definition of the SUM aggregate function in the ANSI ... As long as I don't tell you the second number (it's absent in this ...
    (comp.databases.theory)
  • Re: Null vs. nothing
    ... Null does *not* mean unknown in my understanding of this issue. ... A field that is Null is an empty field in my understanding. ... Anyhow: I hate ZLS strings and hardly ever use them. ...
    (comp.databases.ms-access)
  • Need help with Control Source usage please...
    ... will auto fill the other field, so if you know the unit ... designating one field the Control Source on the Data Tab ... the fields with the designated control source are empty! ... Both fields should show an entry ...
    (microsoft.public.access.gettingstarted)