A97 HELP shows the proper syntax for using Nz as
Nz(variant[, valueifnull])
I'm wondering what to expect from potential past
misuse I've made. For example, consider the following...
Private Sub Command0_Click()
Dim a As Long, b As String
b = Nz(a, "")
MsgBox b
End Sub
a is clearly not a variant, but the Nz function doesn't
really seem to care too much about that fact. I mean,
I get no errors. But that doesn't mean it couldn't be
causing me a problem.
Granted, I've only thought about this for 2 minutes.
But if its of interest to you and if you have time, I
would appreciate your input. Thx. 8 2125
"MLH" <CR**@NorthState.net> wrote in message
news:59********************************@4ax.com... A97 HELP shows the proper syntax for using Nz as Nz(variant[, valueifnull]) I'm wondering what to expect from potential past misuse I've made. For example, consider the following...
Private Sub Command0_Click() Dim a As Long, b As String b = Nz(a, "") MsgBox b End Sub
a is clearly not a variant, but the Nz function doesn't really seem to care too much about that fact. I mean, I get no errors. But that doesn't mean it couldn't be causing me a problem.
Granted, I've only thought about this for 2 minutes. But if its of interest to you and if you have time, I would appreciate your input. Thx.
You might want to view that syntax example as meaning there is no point to
putting anything other than a variant in the Nz command. In the little
procedure that you posted above, the Nz is absolutely meaningless. a is
dimmed as a Long. A Long can never, under any circumstances, be Null.
Randy
True enough. A variant is the only thing that can be.
Does anyone ever put an expression (in place of variant)
in there - perhaps one that might evaluate to Null...
DLookUp("[UName]","tblMyData","[MyID] = -1") where
[MyID] is an AutoNumber field? Or, would that also be
a misuse of the Nz syntax?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx You might want to view that syntax example as meaning there is no point to putting anything other than a variant in the Nz command. In the little procedure that you posted above, the Nz is absolutely meaningless. a is dimmed as a Long. A Long can never, under any circumstances, be Null.
Randy
MLH wrote: True enough. A variant is the only thing that can be. Does anyone ever put an expression (in place of variant) in there - perhaps one that might evaluate to Null... DLookUp("[UName]","tblMyData","[MyID] = -1") where [MyID] is an AutoNumber field? Or, would that also be a misuse of the Nz syntax?
DLookup() will return Null if no records match so using Nz() is appropriate with DLookup.
Dim sName As String
sName = Nz(DLookUp("[UName]","tblMyData","[MyID] = -1"), "<NotFound>")
Here if the name is not found the DLookup() returns Null and the Nz() function then
returns "<NotFound>" and that value is assigned to the String variable sName.
--
'---------------
'John Mishefske
'---------------
> Does anyone ever put an expression (in place of variant)
dim n as long
n = nz(eval("fn()"))
Access 2000, eval converts empty to null, and Nz
without a second parameter converts null back to empty.
(Of course you loose any true null result from the function)
Dim MyFunction(v as variant) as variant
'v is a variant, even if MyFunction was called
'with a string or long parameter: MyFunction(5)
'you can't go the other way: if v is declared as long
'you can't pass a variant parameter
end function
(david)
"MLH" <CR**@NorthState.net> wrote in message
news:s9********************************@4ax.com... True enough. A variant is the only thing that can be. Does anyone ever put an expression (in place of variant) in there - perhaps one that might evaluate to Null... DLookUp("[UName]","tblMyData","[MyID] = -1") where [MyID] is an AutoNumber field? Or, would that also be a misuse of the Nz syntax?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You might want to view that syntax example as meaning there is no point to putting anything other than a variant in the Nz command. In the little procedure that you posted above, the Nz is absolutely meaningless. a is dimmed as a Long. A Long can never, under any circumstances, be Null.
Randy
"MLH" <CR**@NorthState.net> wrote in message
news:s9********************************@4ax.com... True enough. A variant is the only thing that can be. Does anyone ever put an expression (in place of variant) in there - perhaps one that might evaluate to Null... DLookUp("[UName]","tblMyData","[MyID] = -1") where [MyID] is an AutoNumber field? Or, would that also be a misuse of the Nz syntax?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You might want to view that syntax example as meaning there is no point
toputting anything other than a variant in the Nz command. In the little procedure that you posted above, the Nz is absolutely meaningless. a is dimmed as a Long. A Long can never, under any circumstances, be Null.
Randy
Yes. I frequently put DLookUp inside a Nz. Using Nz I can safely assign
the output of a DLookup to a Long or String variable. Otherwise I would
need to assign the output to a variant, then test for Null before assigning
to another datatype.
Many thx to all you folks.
I've found a new toy.
Will begin playing henceforth.
If you think about it you will realize that DLookup MUST be returning
a Variant as it could be returning data from a field of any type.
--
Bri
MLH wrote: True enough. A variant is the only thing that can be. Does anyone ever put an expression (in place of variant) in there - perhaps one that might evaluate to Null... DLookUp("[UName]","tblMyData","[MyID] = -1") where [MyID] is an AutoNumber field? Or, would that also be a misuse of the Nz syntax?
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You might want to view that syntax example as meaning there is no point to putting anything other than a variant in the Nz command. In the little procedure that you posted above, the Nz is absolutely meaningless. a is dimmed as a Long. A Long can never, under any circumstances, be Null.
Randy
Yeah. That makes sense.
xxxxxxxxxxxxxxxxxxxxxxxxxx
On Fri, 21 Oct 2005 20:32:38 GMT, Bri <no*@here.com> wrote: If you think about it you will realize that DLookup MUST be returning a Variant as it could be returning data from a field of any type. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pink Panther |
last post by:
Using the following SQL can the results be explained?
Using A97 (with the SP2 for Jet 3.5) or A2002
CREATE TABLE Test
(PK Number CONSTRAINT PK_TEST PRIMARY KEY, ParentID Number,
Child...
|
by: John Baker |
last post by:
Hi:
I have seen reference to NZ here numeri\ous times, and since my help function is sort of
clobbered I don't have any idea what it really does. Can someone point me in he right
direction to...
|
by: Jean |
last post by:
Hi all,
I am trying to get this query right, but so far no joy...
I have written the following code in the Field box of the QBD grid of
a query:
firstvalue:IIf(Not (IsNull()),,(IIf(Not...
|
by: MLH |
last post by:
For example: Nz(,0) returns "300" if the value in
field is 300 (currency data type) and "0" if the value is
zero or null. I get strings in the query output - they are all left
aligned and I...
|
by: lylefair |
last post by:
The file is now available as
http://www.ffdba.com/downloads/testingNZ3.dat
(rename .dat to .mdb)
or
http://www.ffdba.com/downloads/testingNZ3.mdb
(At time of posting I have not opened the file.)
|
by: Paul |
last post by:
Anyone have code that emulates the Nz function in Microsoft Access?
In Access it is:
Nz(Value as variant, Optional ValueIfNull as Variant) as Variant
|
by: Lyle Fairfield |
last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp
"If the value of the variant argument is Null, the Nz function returns
the number zero or a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| | |