Mestinya ada argumen ke dua mas Harry .
Kalau ada nilai NULL, atau ZERO atau " " di argument 1, gantikan dengan
argumen ke dua.
Untuk kasus sampeyan bisa digunakan sbb:
Address = ""
City = Null
State = "Jakarta"
ZIP = Null
CountryOrRegion = Null
Dim strAddress As String
strAddress = Trim(Nz(Address, Space(0)) & Nz(City, Space(0)) & Nz(State,
Space(0)) & Nz(ZIP, Space(0)) & Nz(CountryOrRegion, Space(0)))
If strAddress = "" Then
MsgBox "There is no address to map."
Else
Application.FollowHyperlink
"http://maps.live.com/default.aspx?where1=" & strAddress
End If
Copy paste dari MS Access Help.
You can use the Nz function to return zero, a zero-length string
<mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1033\vbaac10.c
hm::/html/acfctNZ.htm##> (" "), or another specified value when a
<mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1033\vbaac10.c
hm::/html/acfctNZ.htm##> Variant is
<mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1033\vbaac10.c
hm::/html/acfctNZ.htm##> Null. For example, you can use this function to
convert a Null value to another value and prevent it from propagating
through an expression.
Nz(variant, [valueifnull])
The Nz function has the following arguments.
Argument
Description
variant
A variable of data type
<mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1033\vbaac10.c
hm::/html/acfctNZ.htm##> Variant.
valueifnull
Optional (unless used in a query). A Variant that supplies a value to be
returned if the variant argument is Null. This argument enables you to
return a value other than zero or a zero-length string.
Note If you use the Nz function in an expression in a query without using
the valueifnull argument, the results will be a zero-length string in the
fields that contain null values.
If the value of the variant argument is Null, the Nz function returns the
number zero or a zero-length string (always returns a zero-length string
when used in a query expression), depending on whether the context indicates
the value should be a number or a string. If the optional valueifnull
argument is included, then the Nz function will return the value specified
by that argument if the variant argument is Null. When used in a query
expression, the NZ function should always include the valueifnull argument,
If the value of variant isn't Null, then the Nz function returns the value
of variant.
Remarks
The Nz function is useful for expressions that may include Null values. To
force an expression to evaluate to a non-Null value even when it contains a
Null value, use the Nz function to return zero, a zero-length string, or a
custom return value.
For example, the expression 2 + varX will always return a Null value when
the Variant varX is Null. However, 2 + Nz(varX) returns 2.
You can often use the Nz function as an alternative to the IIf function. For
example, in the following code, two expressions including the IIf function
are necessary to return the desired result. The first expression including
the IIf function is used to check the value of a variable and convert it to
zero if it is Null.
varTemp = IIf(IsNull(varFreight), 0, varFreight)
varResult = IIf(varTemp > 50, "High", "Low")
In the next example, the Nz function provides the same functionality as the
first expression, and the desired result is achieved in one step rather than
two.
varResult = IIf(Nz(varFreight) > 50, "High", "Low")
If you supply a value for the optional argument valueifnull, that value will
be returned when variant is Null. By including this optional argument, you
may be able to avoid the use of an expression containing the IIf function.
For example, the following expression uses the IIf function to return a
string if the value of varFreight is Null.
varResult = IIf(IsNull(varFreight), "No Freight Charge", varFreight)
In the next example, the optional argument supplied to the Nz function
provides the string to be returned if varFreight is Null.
varResult = Nz(varFreight, "No Freight Charge")
Example
The following example evaluates a control on a form and returns one of two
strings based on the control's value. If the value of the control is Null,
the procedure uses the Nz function to convert a Null value to a zero-length
string.
Public Sub CheckValue()
Dim frm As Form
Dim ctl As Control
Dim varResult As Variant
' Return Form object variable pointing to Orders form.
Set frm = Forms!Orders
' Return Control object variable pointing to ShipRegion.
Set ctl = frm!ShipRegion
' Choose result based on value of control.
varResult = IIf(Nz(ctl.Value) = vbNullString, _
"No value.", "Value is " & ctl.Value & ".")
' Display result.
MsgBox varResult, vbExclamation
End Sub
_____
From: [email protected] [mailto:[email protected]]
On Behalf Of Harry siswanto
Sent: Monday, May 17, 2010 10:08
To: belajar-access
Subject: [belajar-access] Tanya Pelajaran Dasar....
Nz = Artinya apa sih ??
apa Not Zero ??
pada ;
Dim strAddress As String
strAddress = Nz(Address)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(City)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(State)
strAddress = strAddress & IIf(strAddress = "", "", ", ") & Nz(Zip)
strAddress = strAddress & IIf(strAddress = "", "", ", ") &
Nz(CountryOrRegion)
If strAddress = "" Then
MsgBox "There is no address to map."
Else
Application.FollowHyperlink "http://maps.
<http://maps.live.com/default.aspx?where1> live.com/default.aspx?where1=" &
strAddress
End If
--
Harry Siswanto
Email: harry.siswanto@ <mailto:[email protected]> gmail.com
http://www.facebook <http://www.facebook.com/harry.siswanto>
.com/harry.siswanto
http://harry- <http://harry-siswanto.blogspot.com/> siswanto.blogspot.com/
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.819 / Virus Database: 271.1.1/2877 - Release Date: 05/16/10
13:26:00