Perform Check on Data

  • Thread starter Thread starter mattc66 via AccessMonster.com
  • Start date 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"
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top