Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

can't pass NULL value

Posted on 2014-09-04
4
Medium Priority
?
109 Views
Last Modified: 2014-09-04
When trying to test for NULL values, I am not able to pass the code below on line 10 when the value is NULL.  Is there something wrong with my syntax on that line?

When debugging, I find that the value is indeed NULL, but it won't pass onto line 11



MonthlyID = 5
ActivityID = 2

If rec.State = adStateOpen Then
        
       rec.MoveFirst
       i = 1
        Do While Not rec.EOF
        
                If rec!ProgressSetback Is Nothing Then
                    If MSFlexGrid1.TextMatrix(i, 9) <> "" Then
                    sStringtoEx = "insert into tblOrgMonthlyProgressSetbacks (PIID, monthlyid, agencyid, progresssetback) values " & _
                    "(" & MSFlexGrid1.TextMatrix(i, 4) & "," & MonthlyID & "," & AgencyID & ",'" & MSFlexGrid1.TextMatrix(i, 9) & "')"
                    Set rec = conn.Execute(sStringtoEx)
                    End If
                End If
                
                If rec!ProgressSetback <> "" Then
                    If MSFlexGrid1.TextMatrix(i, 9) <> "" Then
                    sStringtoEx = "update tblOrgMonthlyProgressSetbacks set progresssetback= '" & MSFlexGrid1.TextMatrix(i, 9) & "' where PIID = " & MSFlexGrid1.TextMatrix(i, 4) & ""
                    Set rec = conn.Execute(sStringtoEx)
                    End If
                End If
                i = i + 1
                rec.MoveNext
   
        Loop
End If

Open in new window

0
Comment
Question by:al4629740
  • 3
4 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 40304222
If IsNull(rec!ProgressSetback) Then
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40304225
Or maybe

If rec!ProgressSetback & " " = " " Then
0
 
LVL 15

Expert Comment

by:ChloesDad
ID: 40304676
As has been implied, NULL and NOTHING are not the same, although it is quite a common error to assume that they are.

Nothing means that the variable does not have an object assigned to it,

Null means that it does have an object assigned to it, but the objects value is NULL
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 40304762
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question