A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access97: Functions cannot return Null???



 
 
Thread Tools Display Modes
  #1  
Old April 20th, 2005, 04:03 AM
Jonathan Scott via AccessMonster.com
external usenet poster
 
Posts: n/a
Default Access97: Functions cannot return Null???

I am writing a function that returns a TableDef, and when there is no
TableDef to return, I try to return Null. Problem is I get a "Object
required" error when I try to assign Null to the function name.(actual
error message is in Japanese, sorry if the error message is not exactly the
same in English)

Fine. I will just catch the error, and return without assigning anything.
But wait, IsNull() is not correctly detecting what should have been a Null
return value!

The compiler likes my assigning a Null for return. Why doesn't the runtime?

Public Function getTable(thisDB As TableDefs, thisTableName As String) As
tableDef
On Error GoTo getTable_ERROR
Set getTable = thisDB(thisTableName)
Exit Function

getTable_ERROR:
Set getTable = Null
End Function

Jonathan Scott

--
Message posted via http://www.accessmonster.com
  #2  
Old April 20th, 2005, 04:19 AM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

I am not sure but try setting the function to Nothing and then check this
with IsObject rather than Null and IsNull().

HTH
Van T. Dinh
MVP (Access)



"Jonathan Scott via AccessMonster.com"
wrote in message news:e63d9bad3599422791df634c4075ec92@AccessMonste r.com...
I am writing a function that returns a TableDef, and when there is no
TableDef to return, I try to return Null. Problem is I get a "Object
required" error when I try to assign Null to the function name.(actual
error message is in Japanese, sorry if the error message is not exactly

the
same in English)

Fine. I will just catch the error, and return without assigning anything.
But wait, IsNull() is not correctly detecting what should have been a Null
return value!

The compiler likes my assigning a Null for return. Why doesn't the

runtime?

Public Function getTable(thisDB As TableDefs, thisTableName As String) As
tableDef
On Error GoTo getTable_ERROR
Set getTable = thisDB(thisTableName)
Exit Function

getTable_ERROR:
Set getTable = Null
End Function

Jonathan Scott

--
Message posted via http://www.accessmonster.com



  #3  
Old April 20th, 2005, 02:07 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default

Jonathan Scott via AccessMonster.com wrote:
I am writing a function that returns a TableDef, and when there is no
TableDef to return, I try to return Null. Problem is I get a "Object
required" error when I try to assign Null to the function name.(actual
error message is in Japanese, sorry if the error message is not
exactly the same in English)

Fine. I will just catch the error, and return without assigning
anything. But wait, IsNull() is not correctly detecting what should
have been a Null return value!

The compiler likes my assigning a Null for return. Why doesn't the
runtime?

Public Function getTable(thisDB As TableDefs, thisTableName As
String) As tableDef
On Error GoTo getTable_ERROR
Set getTable = thisDB(thisTableName)
Exit Function

getTable_ERROR:
Set getTable = Null
End Function

Jonathan Scott


I'm pretty sure that only a function with a return type of variant can
return Null.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


  #4  
Old April 21st, 2005, 07:07 AM
Jonathan Scott via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

I finally got it to work, but I am curious now what the difference could be
between Null and Nothing?

Jonathan Scott

--
Message posted via http://www.accessmonster.com
  #5  
Old April 21st, 2005, 10:06 PM
Van T. Dinh
external usenet poster
 
Posts: n/a
Default

So Nothing works?

An Object variable (including function returning an Object can be a
"Nothing" but not Null AFAIK since Null is an unassigned *value*.

--
HTH
Van T. Dinh
MVP (Access)




"Jonathan Scott via AccessMonster.com" wrote in
message news:a850a4b6a15449f298ac879c18b4eba7@AccessMonste r.com...
I finally got it to work, but I am curious now what the difference could

be
between Null and Nothing?

Jonathan Scott

--
Message posted via http://www.accessmonster.com



  #6  
Old April 26th, 2005, 10:50 AM
david epsom dot com dot au
external usenet poster
 
Posts: n/a
Default

BTW, note the subtle difference in A2000:

'----
public function fn()

end function
'----


?vartype(fn())
0
?isEmpty(fn())
True
?isNull(fn())
False

A97:
? isempty(eval("fn()"))
True
A2000:
isNull(eval("fn()"))
True

In A2000, when a function returns Empty, Eval converts that to Null

(david)


"Jonathan Scott via AccessMonster.com" wrote in
message news:a850a4b6a15449f298ac879c18b4eba7@AccessMonste r.com...
I finally got it to work, but I am curious now what the difference could be
between Null and Nothing?

Jonathan Scott

--
Message posted via http://www.accessmonster.com



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
UNION query question Dale Peart Running & Setting Up Queries 6 July 14th, 2004 12:26 AM
Access inconsistencies Hoopie Running & Setting Up Queries 2 June 15th, 2004 10:53 AM
Using IIF to return a zero value for a null Muraii Running & Setting Up Queries 2 May 29th, 2004 04:06 AM


All times are GMT +1. The time now is 09:48 PM.


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