Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2005, 04:33 PM
bml bml is offline
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default nz function error

Excel doesn't recognize the nz function used in Access queries. I can have a query that runs fine in Access (using the nz function) but when opened from Excel it's not recognized. Is there a reference I can add to make these work, or do I have to rewrite all my sql using an if isnull call instead.

nz(x.FieldName,0) is cleaner than if(isnull(x.FieldName),0,x.FieldName)

Thanks,

Brian

 
Old February 14th, 2005, 12:52 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,

I suggest you write a 'User Defined Function' (UDF).

Function nz(myContent As Variant)
    If IsNull(myContent) Then nz = 0 Else nz = myContent
End Function

then whenever you reference a cell using the =nz(a1) format the cell A1 is evaluated by the function and a result of a number or a letter will be returned.
If, as it appears to be, you are using coded SQL, why not have the conversion routine done at the SQL end so that every record is populated with a real character albeit a blank rather than null.

Cheers

Matthew






Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Function error jijish ASP.NET 2.0 Professional 0 March 7th, 2008 10:57 AM
error function not defined Dj Kat Ajax 6 March 6th, 2006 12:02 PM
Error: Function expected lameneural Java Basics 0 December 1st, 2005 06:57 AM
Undefined Function Error arimakidd Beginning PHP 2 November 10th, 2005 02:54 AM
ASC function Error JpJoe Access 3 May 22nd, 2005 01:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.