Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Fields in recordset from Access with value Null (empty fields)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Fields in recordset from Access with value Null (empty fields)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Fields in recordset from Access with value Null (empty fields)

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fields names do not show in excel 2007 pivot table fields list marlo17 New Users to Excel 2 December 1st 08 01:25 PM
MAX formula and 'empty fields' David Brereton[_2_] Excel Discussion (Misc queries) 1 August 28th 08 01:44 PM
Help with calulating Null fields Roderic Excel Worksheet Functions 3 August 11th 08 10:29 PM
Conditional Linking and Formatting across worksheets to form Summary Page - Only pull/link non-null fields J Leckner Excel Worksheet Functions 1 September 22nd 06 04:18 PM
Excel SHOULD NOT AUTO-CHANGE formated text fields to DATE FIELDS! PSSSD Excel Worksheet Functions 2 August 8th 06 09:31 PM


All times are GMT +1. The time now is 04:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"