doesn't recognize Null value from a field value 
Author Message
 doesn't recognize Null value from a field value

Hello,

Can someone tell me why the code below doesn't work

If Not rst.Fields("Titel").Value = Null Then ti = rst.Fields("Titel").Value

even if the field is not null the if statement doesn't process it's code.
(I'm using VBA in Access)

Thanks in advance,

Sander Janssen.



Wed, 13 Nov 2002 03:00:00 GMT  
 doesn't recognize Null value from a field value
your syntax should be like:

If Not IsNull(rst.Fields("Titel")) Then ti = rst.Fields("Titel")
(you can also ommit the .Value as this is the default property of
fields("Titel") )

--
Ruud

Hello,

Can someone tell me why the code below doesn't work

If Not rst.Fields("Titel").Value = Null Then ti = rst.Fields("Titel").Value

even if the field is not null the if statement doesn't process it's code.
(I'm using VBA in Access)

Thanks in advance,

Sander Janssen.



Wed, 13 Nov 2002 03:00:00 GMT  
 doesn't recognize Null value from a field value
I have a problem with how you placed the not.
If Not rst.Fields("Titel").Value = Null Then ti = rst.Fields("Titel").Value

thus take the not of rst.Fields("Titel").Value and check it to see if it equals null if
it is then do something.  I think you want.
If not (rst.Fields("Titel").Value =  Null) Then
ti = rst.Fields("Titel").Value

The statement then equates to false if the value = null since the not of true or is
equal to is false.  Thus the code does not execute.

The statement then equates to true if the value is not = to null since the not of false
or not = to is true so the code will execute.

This way the code executes if the value is not = to null and will not execute if it is
equal to null.

--
Thanks
Jeff Spicer


Hello,

Can someone tell me why the code below doesn't work

If Not rst.Fields("Titel").Value = Null Then ti = rst.Fields("Titel").Value

even if the field is not null the if statement doesn't process it's code.
(I'm using VBA in Access)

Thanks in advance,

Sander Janssen.



Thu, 14 Nov 2002 03:00:00 GMT  
 doesn't recognize Null value from a field value
You can't use = with Null. It's as simple as that. You must use the IsNull
function:

If Not IsNull(rst.Fields("Titel").Value) Then ....

--

Doug Steele, Microsoft Access MVP
Beer, Wine and Database Programming. What could be better?
Visit "Doug Steele's Beer and Programming Emporium"
http://I.Am/DougSteele/


Quote:
> I have a problem with how you placed the not.
> If Not rst.Fields("Titel").Value = Null Then ti =

rst.Fields("Titel").Value
Quote:

> thus take the not of rst.Fields("Titel").Value and check it to see if it
equals null if
> it is then do something.  I think you want.
> If not (rst.Fields("Titel").Value =  Null) Then
> ti = rst.Fields("Titel").Value

> The statement then equates to false if the value = null since the not of
true or is
> equal to is false.  Thus the code does not execute.

> The statement then equates to true if the value is not = to null since the
not of false
> or not = to is true so the code will execute.

> This way the code executes if the value is not = to null and will not
execute if it is
> equal to null.

> --
> Thanks
> Jeff Spicer



> Hello,

> Can someone tell me why the code below doesn't work

> If Not rst.Fields("Titel").Value = Null Then ti =

rst.Fields("Titel").Value

- Show quoted text -

Quote:

> even if the field is not null the if statement doesn't process it's code.
> (I'm using VBA in Access)

> Thanks in advance,

> Sander Janssen.



Fri, 15 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Field.value doesn't show value in control

2. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

3. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

4. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

5. DATE TIME PICKER DOESN'T SEEM TO RECOGNIZE NULL

6. VB5 Not Recognizing NULL Value

7. CRW 7 doesn't recognize date fields?

8. Recognizing Default Field Value

9. CR and the 'Null' Value

10. Object doesn't support this property or method : 'DTSGlobalVariables(...).Value.Open

11. NULL VALUES IN DATE FIELD - TYPE MISMATCH ERROR

12. Null value in a Numeric field

 

 
Powered by phpBB® Forum Software