472,371 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Puzzling "isNull" failing

I have used isNull statement for as long as I have used VB..

Recently I am devugging a program and it is very clear that the "IsNull"
function sometimes would return a true even when the value is not Null. Any
wild shot or theory as to why this is happening is appreciated. Also, any
other alternative is appreciated since I am stuck and cannot proceed without
fixing this issue (tried = Null and that doesn't work either).

Basically, I have a field in a databsse which could be null, so in the code
i have:

' mfld(x) would have field names like "NAME" etc.

If IsNull(datPrimaryRS.Recordset(mfld(x))) Then
fvalue = ""
Else
fvalue = datPrimaryRS.Recordset(mfld(x))
End If

I have verified by stepping that isNull is true while moving the cursor
shows
"Steven Moss" in datPrimaryRS.Recordset(mfld(x))

What gives?
Apr 15 '06 #1
2 9106

"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:DTY%f.715$UK5.619@trndny01...
I have used isNull statement for as long as I have used VB..

Recently I am devugging a program and it is very clear that the "IsNull"
function sometimes would return a true even when the value is not Null. Any wild shot or theory as to why this is happening is appreciated. Also, any
other alternative is appreciated since I am stuck and cannot proceed without fixing this issue (tried = Null and that doesn't work either).

Basically, I have a field in a databsse which could be null, so in the code i have:

' mfld(x) would have field names like "NAME" etc.

If IsNull(datPrimaryRS.Recordset(mfld(x))) Then
fvalue = ""
Else
fvalue = datPrimaryRS.Recordset(mfld(x))
End If

I have verified by stepping that isNull is true while moving the cursor
shows
"Steven Moss" in datPrimaryRS.Recordset(mfld(x))

What gives?


That is strange.

The situation where IsNull fails with 'Empty' is well-documented. (ie, some
databases will reset a field (text, nullable) that once had a value back to
Empty or " ", and not Null when the value is deleted), and other issues.

But I have never encountered the situation were a value existed and IsNull
failed. However, the Field.Values in a Recordset collection are Variants and
occasionally a strange dance (or joint psychosis) can develop based on the
Field data type attributes, the SQL used to fetch the data, and whether you
have previous dereferenced the value in your code.

You might go back and see if you can find something unusual about this
particular Field and its history.

There is simple workaround in this case. Use this instead...
fvalue = datPrimaryRS.Recordset(mfld(x)) & ""

hth
-ralph

Apr 15 '06 #2

"Ralph" <nt*************@yahoo.com> wrote in message
news:1u******************************@arkansas.net ...

"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:DTY%f.715$UK5.619@trndny01...
I have used isNull statement for as long as I have used VB..

Recently I am devugging a program and it is very clear that the "IsNull"
function sometimes would return a true even when the value is not Null. Any
wild shot or theory as to why this is happening is appreciated. Also, any other alternative is appreciated since I am stuck and cannot proceed

without
fixing this issue (tried = Null and that doesn't work either).

Basically, I have a field in a databsse which could be null, so in the

code
i have:

' mfld(x) would have field names like "NAME" etc.

If IsNull(datPrimaryRS.Recordset(mfld(x))) Then
fvalue = ""
Else
fvalue = datPrimaryRS.Recordset(mfld(x))
End If

I have verified by stepping that isNull is true while moving the cursor
shows
"Steven Moss" in datPrimaryRS.Recordset(mfld(x))

What gives?


That is strange.

The situation where IsNull fails with 'Empty' is well-documented. (ie,

some databases will reset a field (text, nullable) that once had a value back to Empty or " ", and not Null when the value is deleted), and other issues.

But I have never encountered the situation were a value existed and IsNull
failed. However, the Field.Values in a Recordset collection are Variants and occasionally a strange dance (or joint psychosis) can develop based on the
Field data type attributes, the SQL used to fetch the data, and whether you have previous dereferenced the value in your code.

You might go back and see if you can find something unusual about this
particular Field and its history.

There is simple workaround in this case. Use this instead...
fvalue = datPrimaryRS.Recordset(mfld(x)) & ""

hth
-ralph


Ralph..

You have no idea how valuable your golden advice is!!

Obviously the test for null is needed since we will get an
invalid use of null when we try to assign it to a variable/

Your method however, not only works, but it is a much more
efficient way of coding the isNull test..

Thanks again bud..
Apr 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent...
1
by: Gilz | last post by:
Hi I was wondering if anyone could help i have picked this database up from a designer who has now left the company. The code is a couple of years old. On click of a button it open a...
2
by: Hexman | last post by:
Hello All, In SS EE I have nulls in a column. I want to select and eventually change to a zero (its a smallint column). I've tried selecting 'null', 'dbnull', etc. Then I read about the ISNULL...
9
by: Drum2001 | last post by:
Hello All! I am using the following code during an On Click event for a button. It works properly to create a query for a report: Private Sub Command14_Click() If IsNull(Me.Text30) Then ' No...
6
by: KiwiGenie | last post by:
Hi..I am trying to make a search form. I am fairly new to access and could well be looking at it completely wrong. I have an unbound form with textboxes in the header for entering different search...
0
by: zensunni | last post by:
The script I've made checks for identical fields in the database before it inserts a new row. However, there is one number that, when checked for, will not be found. It assumes there is no row, so it...
13
by: clarencemo | last post by:
Hello, I currently have a split db and I keep getting this error after about a day's worth of use. Once I've repaired it, I have created a clean db, imported the tables from a previous backup and...
4
kcdoell
by: kcdoell | last post by:
Hello: I have the following afterupdate event: Private Sub GWP_AfterUpdate() 'Updates the Total calculation in the control "SumGWP" on the quick reference 'table that is located on the form...
22
by: MLH | last post by:
100 Dim db As Database, rst As Recordset 120 Set db = CurrentDb 140 PString = "SELECT qryBatchList.ReadyFor906, qryBatchList.BatchID FROM qryBatchList WHERE...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.