Fields in recordset from Access with value Null (empty fields)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
In an Excel VBA routine data from Access are reported to an Excelsheet with
recordsets and loops for the number of items.
It works OK when the field have got values but I can´t get it to work with
empty fields (value Null).

I have tried like this
"If rs1.Fields("TextCell").Value = Null Then
Else
strCelltext = rs1.Fields("TextCell").Value"
but even if the field is empty it will get on to the line after Else.
Thanks in advance with any help.
All the best
Mats
 
Use an intermediate function to handle errors. For example:

public function NotNull( rsRecord as object ) as string
on error goto ErrHandler

NotNull = rsRecord

exit function
ErrHandler:
NotNull = ""
end function

....
strCelltext = NotNull( rs1.Fields("TextCell") )
....
 
Hi Bill,
Thanks for your answer.
I found the function isnull(expression) in the VBA help and I think that
function also will work.
/Mats
 
Back
Top