![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I used the Nz() function in a query to replace blank entries with zero so that a subsequent SUM function wouldn't trip over. However, it meant that I couldn't format the resulting number when displayed in a form. Is this a feature of the Nz() function or am I doing something wrong. |
#3
| |||
| |||
|
|
In queries, IIf() is better than Nz(). Instead of: Nz([Amount], 0) use: IIf([Amount] Is Null, 0, [Amount]) Access will then understand the data type correctly. The issue is that Nz() returns a Variant, which has a meaningful subtype in VBA but is not recognised by JET. Consequently JET treats it as text by default. IIf() does not have this problem. An alternative is to explicitly typecast the result of Nz(), e.g.: CCur(Nz([Amount],0)) This is generally less efficient, but sometimes handy. |
#4
| |||
| |||
|
|
I used the Nz() function in a query to replace blank entries with zero so that a subsequent SUM function wouldn't trip over. |
|
However, it meant that I couldn't format the resulting number when displayed in a form. Is this a feature of the Nz() function or am I doing something wrong. |
#5
| |||
| |||
|
|
In queries, IIf() is better than Nz(). Instead of: Nz([Amount], 0) use: IIf([Amount] Is Null, 0, [Amount]) Access will then understand the data type correctly. The issue is that Nz() returns a Variant, which has a meaningful subtype in VBA but is not recognised by JET. Consequently JET treats it as text by default. IIf() does not have this problem. |
#6
| |||
| |||
|
|
In queries, IIf() is better than Nz(). Instead of: Nz([Amount], 0) use: IIf([Amount] Is Null, 0, [Amount]) Access will then understand the data type correctly. The issue is that Nz() returns a Variant, which has a meaningful subtype in VBA but is not recognised by JET. Consequently JET treats it as text by default. IIf() does not have this problem. An alternative is to explicitly typecast the result of Nz(), e.g.: CCur(Nz([Amount],0)) This is generally less efficient, but sometimes handy. -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users -http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "franc sutherland" <franc.sutherl... (AT) googlemail (DOT) com> wrote in message news:f97e269a-80ee-4997-bf12-68edb00c1b73 (AT) c33g2000hsd (DOT) googlegroups.com... I used the Nz() function in a query to replace blank entries with zero so that a subsequent SUM function wouldn't trip over. However, it meant that I couldn't format the resulting number when displayed in a form. Is this a feature of the Nz() function or am I doing something wrong. |
#7
| |||
| |||
|
|
On Fri, 7 Mar 2008 14:37:16 +0900, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid wrote: In queries, IIf() is better than Nz(). Instead of: Nz([Amount], 0) use: IIf([Amount] Is Null, 0, [Amount]) Access will then understand the data type correctly. The issue is that Nz() returns a Variant, which has a meaningful subtype in VBA but is not recognised by JET. Consequently JET treats it as text by default. IIf() does not have this problem. An alternative is to explicitly typecast the result of Nz(), e.g.: CCur(Nz([Amount],0)) This is generally less efficient, but sometimes handy. Another way to typecast is to force a numeric calculation. eg. Nz([Amount])+0 Wayne Gillespie Gosford NSW Australia |
#8
| |||
| |||
|
|
franc sutherland <franc.sutherl... (AT) googlemail (DOT) com> wrote in news:f97e269a- 80ee-4997-bf12-68edb00c1... (AT) c33g2000hsd (DOT) googlegroups.com: I used the Nz() function in a query to replace blank entries with zero so that a subsequent SUM function wouldn't trip over. Could you tell us of a situation where SUM trips over nulls. However, it meant that I couldn't format the resulting number when displayed in a form. Is this a feature of the Nz() function or am I doing something wrong. It's not a feature of the Nz Function. |
#9
| |||
| |||
|
|
On Mar 7, 11:24 am, lyle fairfield <lylef... (AT) yah00 (DOT) ca> wrote: franc sutherland <franc.sutherl... (AT) googlemail (DOT) com> wrote in news:f97e269a- 80ee-4997-bf12-68edb00c1... (AT) c33g2000hsd (DOT) googlegroups.com: I used the Nz() function in a query to replace blank entries with zero so that a subsequent SUM function wouldn't trip over. Could you tell us of a situation where SUM trips over nulls. However, it meant that I couldn't format the resulting number when displayed in a form. Is this a feature of the Nz() function or am I doing something wrong. It's not a feature of the Nz Function. Hi Lyle, Sorry, my mistake there. It wasn't using the SUM function within a query which caused the problem. It was adding the fields together in a subsequent form which gave '#error'. Does that make more sense? All the best, Franc. |
![]() |
| Thread Tools | |
| Display Modes | |
| |