UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Nz Function, Access 2010    
 
   
edin14166
post Nov 20 2017, 08:30 AM
Post#1



Posts: 299
Joined: 15-November 05
From: BiH


Hello,
I have problem using Nz function when I want to use it with this :

Nz(=Diff2Dates("dhn";[datum];[datumPovratak]),[0] )

what should I change here ?

Thanks in advance...
Go to the top of the page
 
DanielPineault
post Nov 20 2017, 08:35 AM
Post#2


UtterAccess VIP
Posts: 5,452
Joined: 30-June 11



Hard to say since you don't explain what you would like to achieve exactly, but I suspect you want something more like

CODE
Nz(Diff2Dates("dhn", [datum], [datumPovratak]), 0)


Also, where is this being used? Query, VBA? Are [datum] and [datumPovratak] fields or variables?

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
edin14166
post Nov 20 2017, 08:39 AM
Post#3



Posts: 299
Joined: 15-November 05
From: BiH


tahnks for response but it does not work.
I have error saying that Exspressions must begin with equal sign = .....

Function : =Diff2Dates("dhn";[datum];[datumPovratak])

is used to get diference between dates on a form...
Go to the top of the page
 
GroverParkGeorge
post Nov 20 2017, 09:01 AM
Post#4


UA Admin
Posts: 31,234
Joined: 20-June 02
From: Newcastle, WA


PMFJI:
You need to assign the results of this expression to a variable, or to a control in a form or report, or to a field in a query.

Perhaps:

YourVariableNameGoesHere = Nz(Diff2Dates("dhn", [datum], [datumPovratak]), 0)

Or something like that.

If you want to use it as the control source for a control on a form, put it into the control's control source property, using the = sign as you indicated.

--------------------
Go to the top of the page
 
edin14166
post Nov 20 2017, 09:27 AM
Post#5



Posts: 299
Joined: 15-November 05
From: BiH


'' If you want to use it as the control source for a control on a form, put it into the control's control source property, using the = sign as you indicated. ''

but it does not work. the sintax is wrong somewhere:


Nz(Diff2Dates("dhn";[datum];[datumPovratak]),0 )
Go to the top of the page
 
BruceM
post Nov 20 2017, 09:32 AM
Post#6


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


Did you try adding the = sign?

=Nz(Diff2Dates("dhn";[datum];[datumPovratak]),0)
Go to the top of the page
 
edin14166
post Nov 20 2017, 09:35 AM
Post#7



Posts: 299
Joined: 15-November 05
From: BiH


Yes and get error :
The expression you entered contains invalid sintax
Go to the top of the page
 
GroverParkGeorge
post Nov 20 2017, 09:36 AM
Post#8


UA Admin
Posts: 31,234
Joined: 20-June 02
From: Newcastle, WA


I just noticed. You are using the ; as a delimiter. It should be the ,

Also, I assume that Diff2Dates is a function written by someone? It's not the actual VBA function, which is DateDiff()

=Nz(Diff2Dates("dhn",[datum],[datumPovratak]),0)

--------------------
Go to the top of the page
 
edin14166
post Nov 20 2017, 09:38 AM
Post#9



Posts: 299
Joined: 15-November 05
From: BiH


same error......
Go to the top of the page
 
River59
post Nov 20 2017, 09:38 AM
Post#10



Posts: 1,347
Joined: 7-April 10
From: Detroit, MI


QUOTE
=Nz(Diff2Dates("dhn";[datum];[datumPovratak]),0)


MyVariable = Nz(DateDiff("dhn",[datum],[datumPovratak]),0)

I have no idea what function Diff2Dates is, I use DateDiff. Also you had semi-colons rather than commas between the fields.

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
BruceM
post Nov 20 2017, 09:54 AM
Post#11


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


I have seen Diff2Dates before. I expect it is the function described here.

I also missed that you are using semicolons instead of commas. Somebody asked a question earlier, which you did not answer: what are datum and datumPovratak? Fields? Variables?
Go to the top of the page
 
River59
post Nov 20 2017, 10:13 AM
Post#12



Posts: 1,347
Joined: 7-April 10
From: Detroit, MI


Thanks, Bruce.

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
DanielPineault
post Nov 20 2017, 10:42 AM
Post#13


UtterAccess VIP
Posts: 5,452
Joined: 30-June 11



Edin14166

We need you to answer the question regarding where you are trying to use this line? What datum & datumPovratak represent.
Also, on your PC, what is the list separator ; or ,? Based on that you need to use it throughout your function calls.

You also need to either post the full SQL statement or VBA procedure and we'll be able to better guide you.

Lastly, have you tried using the Diff2Dates() on it's own just to see if you get the syntax proper?

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
edin14166
post Nov 21 2017, 02:28 AM
Post#14



Posts: 299
Joined: 15-November 05
From: BiH


Bruce,
fields datum & datumPovratak are in table date fields whith wich I calculate difference in time between them and
function
=Diff2Dates("dhn";[datum];[datumPovratak])

works fine but when I try to use it in Nz function it does not work..
Go to the top of the page
 
edin14166
post Nov 21 2017, 02:31 AM
Post#15



Posts: 299
Joined: 15-November 05
From: BiH


Yes this is the function.
The fields are table date fields.
Go to the top of the page
 
GroverParkGeorge
post Nov 21 2017, 07:41 AM
Post#16


UA Admin
Posts: 31,234
Joined: 20-June 02
From: Newcastle, WA


So you are confirming that your settings use the semi-colon, not the comma as the delimiter?

--------------------
Go to the top of the page
 
BruceM
post Nov 21 2017, 08:11 AM
Post#17


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


I wonder: If Diff2Dates works with the semicolon as the delimiter, what would happen if the semicolon is used with Nz? In other words, use the same delimiter for every function.
Go to the top of the page
 
DanielPineault
post Nov 21 2017, 08:33 AM
Post#18


UtterAccess VIP
Posts: 5,452
Joined: 30-June 11



QUOTE
I wonder: If Diff2Dates works with the semicolon as the delimiter, what would happen if the semicolon is used with Nz? In other words, use the same delimiter for every function.

Yes and No. The examples (from the URL) clearly show commas, but then again,it will use whatever the list separator is in your regional settings.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
DanielPineault
post Nov 21 2017, 08:36 AM
Post#19


UtterAccess VIP
Posts: 5,452
Joined: 30-June 11



If you need the =, then I'm assuming this is an expression being directly entered in a control? You still haven't explained your usage (Query, VBA, ...), this does make a difference and why we've asked you numerous times.

One of these must work,.

Using a comma as the delimiter (this is the more standard US/CAN/.. delimiter)
CODE
=Nz(Diff2Dates("dhn", [datum], [datumPovratak]), 0)


Using a semicolon as the delimiter (I think this may be your case, I think your Regional Setting use a semicolon rather than a comma)
CODE
=Nz(Diff2Dates("dhn"; [datum]; [datumPovratak]); 0)

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
BruceM
post Nov 21 2017, 08:40 AM
Post#20


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


QUOTE
The examples clearly show commas

The examples posted by the OP showed the semicolon to separate the Diff2Dates arguments, and the comma to separate the Nz arguments. Responses showed a consistent use of the delimiter, but it is not clear if the OP applied consistent usage.
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search
RSSSearch   Top   Lo-Fi    15th December 2017 - 08:40 PM