Perform Check on Data

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

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"
 
M

Marshall Barton

mattc66 said:
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.
 
M

mattc66 via AccessMonster.com

That works great- Thanks.

Marshall said:
I have an Order Form that I want to perform a check on the data when the user
selects a Check Box.
[quoted text clipped - 18 lines]
& 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.
 
Top