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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Nz Not Returning Desired Value From Another Form, Access 2016    
 
   
Snoopy
post Nov 5 2019, 03:51 PM
Post#1



Posts: 9
Joined: 4-November 19



Having Strange results when trying to get values from another form.

Here is my simplified version showing the issue...

Local referencing works:
CODE
tbR1 = Nz(tbExtendedPrice1, 0)
tbR2 = Nz(tbExtendedPrice2, 0)
tbR3 = Nz(tbExtendedPrice3, 0)
tbR4 = Nz(tbExtendedPrice4, 0)
tbR5 = Nz(tbExtendedPrice5, 0)
tbR6 = Nz(tbExtendedPrice6, 0)
And I get all the values and a Zero for the Extended Prices that are Null. Works fine.

Trying to reference another form gives no run-time errors, but the Null values are not converted to Zero.
CODE
tbR1 = Nz(Forms!frmCreateInvoice!tbExtendedPrice1, 0)
tbR2 = Nz(Forms!frmCreateInvoice!tbExtendedPrice2, 0)
tbR3 = Nz(Forms!frmCreateInvoice!tbExtendedPrice3, 0)
Values come through, but I get no Zero

I even tried
CODE
tbR3 = Nz(Forms!frmCreateInvoice!tbExtendedPrice3.Value, 0)
but still no Zero comes through.


As I am wanting to do some addition of fields, if I can't get a Zero, I can't add.

Please point out the error of my ways....
Go to the top of the page
 
theDBguy
post Nov 5 2019, 04:14 PM
Post#2


UA Moderator
Posts: 77,721
Joined: 19-June 07
From: SunnySandyEggo


Hi. Welcome to UA! welcome2UA.gif

If you go to the Immediate Window and enter this, what do you get?
CODE
?Nz(Forms!frmCreateInvoice!tbExtendedPrice1, 0)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Snoopy
post Nov 5 2019, 04:23 PM
Post#3



Posts: 9
Joined: 4-November 19



Thanks for the quick look...

Running the test in the Immediate Window gives me a blank line.

No Zero in sight (for known null text boxes).

Proper value is returned for valued text boxes.
Go to the top of the page
 
June7
post Nov 5 2019, 04:31 PM
Post#4



Posts: 1,306
Joined: 25-January 16
From: The Great Land


If you want to provide db for analysis, follow instructions at bottom of my post.

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
 
theDBguy
post Nov 5 2019, 04:51 PM
Post#5


UA Moderator
Posts: 77,721
Joined: 19-June 07
From: SunnySandyEggo


Hi. That tells me the textbox may not be null. What happens if you do this?
CODE
?IsNull(Forms!frmCreateInvoice!tbExtendedPrice1)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Snoopy
post Nov 5 2019, 05:05 PM
Post#6



Posts: 9
Joined: 4-November 19



THANKS DBguy
You nailed it...

Local test was to nulls.

Remote was to Zero length string... Darn it I couldn't see the difference...

Now I need to code the check before using.

Thanks again.

And While uarulez2.gif

It is Really the Contributors (who help plebs like me) that RULE
Go to the top of the page
 
theDBguy
post Nov 5 2019, 05:17 PM
Post#7


UA Moderator
Posts: 77,721
Joined: 19-June 07
From: SunnySandyEggo


Hi. Congratulations! Glad to hear you got it sorted out. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
cheekybuddha
post Nov 5 2019, 06:18 PM
Post#8


UtterAccess Moderator
Posts: 12,620
Joined: 6-December 03
From: Telegraph Hill


If you really want to allow zero-length strings you can use:
CODE
tbR1 = IIf(tbExtendedPrice1 & vbNullString <> vbNullString, tbExtendedPrice1, 0)

which will handle both NULL and ZLS.

But probably better to avoid ZLS unless there is a specific need.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    2nd April 2020 - 05:55 PM