473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

calculation fields acts abnormal

I am in a confusion that my access query calculated fields results abnormal where as the same query displays correct result in another query. Picture attached

i have a query1 field NjdActInvent:Nz([NJDinventory])+Nz([NjdPurchOrder])-Nz([njdSaleOrder])

[njdinventory] is 75 , [njdpurchOrder] is 295, [njdSaleOrder] is null but the result in [NjdActInvent] fiels shows the result 75295

i have query2 field
WhActInvent: Nz([whinventory])+Nz([whPurchOrder])-Nz([WHsaleOrder])

[whinventory] is 1435 , [whPurchOrder] is 298, [WHsaleOrder] is null but the result shows correctly as in [WhActInvent] 1137.

why the query1 filed shows wrong result. Anybody can help please.....

Attached Images
File Type: jpg 20160409071250.jpg (84.2 KB, 207 views)
File Type: jpg correct result.jpg (70.7 KB, 193 views)
Apr 9 '16 #1

✓ answered by Stewart Ross

The values you are trying to add and subtract are being converted to text by the database engine's interpretation of the result returned by the non-null function (Nz) - which is why 75 + 295 is returning 75295. In your screenshots you will see that these values are left-aligned - a give-away that they have been converted to text. Numeric values always default to being shown right-aligned.

If you want to continue using Nz you should wrap each call with a conversion back to numeric form. The simplest way to do it would be to use the Val function:

Expand|Select|Wrap|Line Numbers
  1. WhActInvent: Val(Nz([whinventory]))+Val(Nz([whPurchOrder]))-Val(Nz([WHsaleOrder]))

-Stewart

3 1030
Stewart Ross
2,545 Expert Mod 2GB
The values you are trying to add and subtract are being converted to text by the database engine's interpretation of the result returned by the non-null function (Nz) - which is why 75 + 295 is returning 75295. In your screenshots you will see that these values are left-aligned - a give-away that they have been converted to text. Numeric values always default to being shown right-aligned.

If you want to continue using Nz you should wrap each call with a conversion back to numeric form. The simplest way to do it would be to use the Val function:

Expand|Select|Wrap|Line Numbers
  1. WhActInvent: Val(Nz([whinventory]))+Val(Nz([whPurchOrder]))-Val(Nz([WHsaleOrder]))

-Stewart
Apr 9 '16 #2
Val function was not useful in my case thats why i used clang function. My tables are linked with sql table . So the quantity field is taken as text in access , i made a query to convert that using clng function
Apr 9 '16 #3
Thank you stewart....... it worked...
Apr 10 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Reynard Hilman | last post by:
Hi, I have been having this problem where the database size suddenly grows from the normal size of about 300Mb to 12Gb in one night. When I look up the table size, the biggest one is only 41Mb...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
1
by: gjoneshtfc | last post by:
Hello, I have an asp page that is a table. In the table the end column is a calculation of other values, for example: ...
3
by: FrozenDude | last post by:
I've implemented Allen Browne's Audit Log and it works quite well (thanks). However, my form has a series of calculated fields that fire on the form OnCurrent event. The calculation causes a...
11
by: Xaysana12345 | last post by:
Hi there, I am having problem with form and report calculation fields showing #Num. ex. fieldA/fieldB if either fieldA or B=null, in the result field obtains #Num. How can I figure out? ...
5
by: =?Utf-8?B?amVsbGU3OQ==?= | last post by:
Hi, I want to use a difficult Excelsheet as source for my calculation in a ASP.NET (C#) page. I have 5 input fields on my ASP.NET page and when I press the submit button I want to put these...
2
by: hcso | last post by:
We have a form that has unbound calculation fields that we want to link to a table. Both the form and the table have already been created. How should I start my Visual Basics entry? I keep trying...
0
by: notmoonlighting | last post by:
I am new to Access 2007, a former FileMaker Pro database user. I am trying to replicate some functionality that was available in the FM DB, which involved Calculated Fields in one of the Tables. ...
1
by: robadob1212 | last post by:
I'm creating a form in Adobe Acrobat 9 Pro. The form has 9 text fields. In the first 8 fields, the user manually enters a dollar amount. The ninth field has a calculation that auto-populates...
0
by: visionplustrams | last post by:
I have to present on the topic "Measuring DB2 activity in terms of MSU / MIPS". My client wants to know the current MSU / MIPS utilization trend for his existing DB2 v8 so that he can decide on how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.