Checking for Null Values.

Can anyone tell me how to check for a Null value when I read an Access record ?

Because I'm using BindingContext it seems that the program reads a record, and in this particular instance i'm trying to move the 1 character data from the Db field into a Textbox on my form. My textbox isn't bound to the Db field so I'm moving the data manually.

Here is the statement I'm trying to use.


editWOStatus.Text = wrkds.Tables("WO Listing").Rows(BindingContext(WoHeaderDS, _
"WO Listing").Position).Item("WOStatus")

Now there shouldn't be an instance where this field is Blank but I want to be able to handle any anomally that comes along.

If there is no data in this 1 char field the program crashes saying that it can't read a Null value so I would like to check for it.

tanks in advance

tattoo

[1214 byte] By [tattoo] at [2007-12-24]
# 1

Well, there's always the old standby function IsDbNull().

But the DataRow object should also have a IsNull() method.

So the preferred way would be:

if wrkds.Tables("WO Listing").Rows(BindingContext(WoHeaderDS, _
"WO Listing").Position).IsNull("WOStatus") Then

But you could also use:

if IsDbNull(wrkds.Tables("WO Listing").Rows(BindingContext(WoHeaderDS, _
"WO Listing").Position).Item("WOStatus")) Then

HTH

rkimble at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks Reed, this works perfectly.

tattoo

tattoo at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...