Harry, you are correct. I'm used to working with NZ in VBA code, not queries. In VBA code, the DEFAULT value of that second parameter is ZERO if you're working with a number type (such as an ID) otherwise it's a zero-length string. MOST of the time I'm working with NZ it's for looking up IDs to see if records exist, so you don't need to specify it.
From Microsoft's Help: 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.
So, ideally, when working with queries, always make sure to specify the zero. Thank you, Harry.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Microsoft Access 325.