Calculate stock qty with query

mischa

Registered User.
Local time
Today, 22:44
Joined
Jul 25, 2013
Messages
63
I have a problem with calculating the total qty of two fields.

Code:
QtyMapics: Nz([MapicsQty];0)
QtySubComp: Nz([SubComponentQty];0)
TotalQty: [QtyMapics]+[QtySubComp]

When I calculate the values of the fields it pastes the values after each other.
For example: if you have the values 1 and 2 (which should become 3) then the result is a value of 12.

I've tried changing the function to SUM() but that didn't work.

The reason I am using NZ() is due to the fact that some values have a NULL value in one or both of the fields and if NZ is not included it will not calculate anything.
 
For example: if you have the values 1 and 2 (which should become 3) then the result is a value of 12.

When you get result 12, it indicates you are concatenating 2 text strings.
eg "1" +"2" ===> "12"
also "1" & "2 ===12

You add numeric datatypes.

You can convert a string to integer using CInt()

I'm not sure where you are located, but your Nz syntax is not familiar.
 
Try,
Code:
QtyMapics: CLng(Nz([MapicsQty];0))
QtySubComp: CLng(Nz([SubComponentQty];0))
TotalQty: [QtyMapics]+[QtySubComp]
 
Thank you very much jdraw and Paul :D !!
The CLng did the job.
 

Users who are viewing this thread

Back
Top Bottom