Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- ESI Update |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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") ) .... "Mats Nilsson" wrote: 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 -- ESI Update |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- ESI Update "Bill Pfister" wrote: 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") ) ... "Mats Nilsson" wrote: 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 -- ESI Update |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
fields names do not show in excel 2007 pivot table fields list | New Users to Excel | |||
MAX formula and 'empty fields' | Excel Discussion (Misc queries) | |||
Help with calulating Null fields | Excel Worksheet Functions | |||
Conditional Linking and Formatting across worksheets to form Summary Page - Only pull/link non-null fields | Excel Worksheet Functions | |||
Excel SHOULD NOT AUTO-CHANGE formated text fields to DATE FIELDS! | Excel Worksheet Functions |