puzzle... (1 Viewer)

ariel81

Registered User.
Local time
Yesterday, 21:35
Joined
Dec 31, 2006
Messages
75
i have this code:
Code:
 If IsNull(rs![tblFltTotalJobsAE] Or rs![tblFltTotalJobsEI] Or rs![tblFltTotalJobsRC]) = False Then
             a = a + rs![tblFltTotalJobsAE]
             b = b + rs![tblFltTotalJobsEI]
             c = b + rs![tblFltTotalJobsRC]
             d = a + b + c
             
          
                 f("test2") = d
            
              End If

the result of the abv code eg:
rs![tblFltTotalJobsAE] <- 2
rs![tblFltTotalJobsEI] <- 3
rs![tblFltTotalJobsEI] <- 4
f("test2") = 9 , the result will be 9 (correct!)

if any of the rs![ ] is a null,
rs![tblFltTotalJobsAE] <- 2
rs![tblFltTotalJobsEI] <-
rs![tblFltTotalJobsEI] <- 4
f("test2") = **empty data** , the result should be 6 but the textbox is blank.

why the abv code doesn't seems to add up records whenever any of the records is empty?
 

neileg

AWF VIP
Local time
Today, 05:35
Joined
Dec 4, 2002
Messages
5,975
Null isn't the same as zero. Look at the Nz() function.
 

Bat17

Registered User.
Local time
Today, 05:35
Joined
Sep 24, 2004
Messages
1,687
If IsNull(rs![tblFltTotalJobsAE] Or rs![tblFltTotalJobsEI] Or rs![tblFltTotalJobsRC]) = False Then

this will always return false as you are asking a logic question and you will get either a 0 or 1 retuned by the brackets

Peter
 

RuralGuy

AWF VIP
Local time
Yesterday, 22:35
Joined
Jul 2, 2005
Messages
13,826
Peter,
I can't come up with a test right now but I believe *any* non 0 value will be interpreted and a True.
 

Bat17

Registered User.
Local time
Today, 05:35
Joined
Sep 24, 2004
Messages
1,687
Just done a quick check
Code:
Dim a, b, c
Dim d As Boolean
d = (a Or b Or c)
Debug.Print d

Prints False

Peter
 

Bat17

Registered User.
Local time
Today, 05:35
Joined
Sep 24, 2004
Messages
1,687
The point really is that the logic test will give 1 or 0 so isnull will alway answer False

Peter
 

RuralGuy

AWF VIP
Local time
Yesterday, 22:35
Joined
Jul 2, 2005
Messages
13,826
Hi Peter,
Try this one:
Code:
Dim a, b, c
Dim d As Boolean
a = 1
d = (a Or b Or c)
Debug.Print d
 

RuralGuy

AWF VIP
Local time
Yesterday, 22:35
Joined
Jul 2, 2005
Messages
13,826
Hi Peter,
How about:
Code:
Dim d As Boolean
d = IsNull(Null Or Null Or Null)
Debug.Print d
 

Bat17

Registered User.
Local time
Today, 05:35
Joined
Sep 24, 2004
Messages
1,687
oop :(
Always thought a variant was a null not an "" before it was assigned.

Suppose that this is a case of Nulls propagating again, but then why does it not always end up with a null

Peter
 

RuralGuy

AWF VIP
Local time
Yesterday, 22:35
Joined
Jul 2, 2005
Messages
13,826
OR does not propagate a null but + does.
 

Users who are viewing this thread

Top Bottom