- nz(DSum("[quantityindetail]*[purchaseprice]-[quantityindetail]*[purchaseprice]*DiscPurchasedetail*0.01","Purchasedetail","[purchaseid]= '" & [Purchaseid] & "'"),0) AS sub_total
-
-
nz(DSum("[vatvaluePurchasedetail]","Purchasedetail","[purchaseid]= '" & [Purchaseid] & "'"),0) AS vat_sum
I am running this two functions in a query.
What I am trying to do is adding - vat_sum + sub_total as grandtotal
it is working but as string. example 25+5=255
How may I tell the DSUM to return me a number value in place of string ?
any idea it would be appreciated
Thank you in advance
WASSIM S DACCACHE
4 4689
What Datatypes are vat_sum and sub_total?
Linq ;0)>
Hi Wassim. It's not DSum that returns the string - it's the Nz function. You can convert each Nz string value back to a number using one of the type conversion functions as necessary: - CCur(Nz(DSum..., 0)) ' convert to currency value
-
CDbl(Nz(DSum..., 0)) ' convert to double-precision floating point
-
CLng(Nz(DSum..., 0)) ' convert to long integer
or you can use the Val function to take the numeric value of each string instead
However, as Linq has pointed out you should ensure that the type of the variables or fields you are assigning these values to is correct. Access normally does type conversion 'on the fly' - if the result is assigned to a double-precision value, say, then Access would convert the Nz results to floating-point numbers before performing the sum. It suggests you have a text result type somewhere.
-Stewart
Hi Wassim. It's not DSum that returns the string - it's the Nz function. You can convert each Nz string value back to a number using one of the type conversion functions as necessary: - CCur(Nz(DSum..., 0)) ' convert to currency value
-
CDbl(Nz(DSum..., 0)) ' convert to double-precision floating point
-
CLng(Nz(DSum..., 0)) ' convert to long integer
or you can use the Val function to take the numeric value of each string instead
However, as Linq has pointed out you should ensure that the type of the variables or fields you are assigning these values to is correct. Access normally does type conversion 'on the fly' - if the result is assigned to a double-precision value, say, then Access would convert the Nz results to floating-point numbers before performing the sum. It suggests you have a text result type somewhere.
-Stewart
Thank you for your reply. I used the VAL () function and it is converting the string to number.
but I didn't understand why it is replying me a string since i used the dsum function without the NZ () function also the dsum function is doing the sum of fields that datatypes are double.
regards,
It's just one of many quirks in Access! When used in a query, Nz() always returns a string!
Linq ;0)>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lawrence |
last post by:
I'm learning Javascript. I downloaded a script for study. Please tell
me how the variable "loop" can have scope in the first function when
it is altered in the second function? It is not defined...
|
by: Rolan |
last post by:
I'm using Access 97 and need some assistance in sorting out a proper
DSum expression. It relates to a subform (sfrmCost) from which I'm
wanting to extract the grand total of any and all data rows...
|
by: Dalan |
last post by:
I have tried both methods of using DSum and creating a Function to
address summing some number columns, but to no avail. Since this has
been a popular topic over the years, I'm sure I'll receive...
|
by: John Baker |
last post by:
Hi:
I have a form, and wish to show on the form the current total for a single field on a
table. I have set this up thus: =DSum(,!) in an unbound
text field. These are correct field and table...
|
by: GD |
last post by:
tblFoo
FooId Name Number
1 One 1
2 Two 2
3 Three 3
The Following query produces the results I want, but it is not
updatable. I need at least the...
|
by: beppe005 |
last post by:
I would like to calculate a total for all the field with the same
in a query.
I don't know how to set the "criteria" for this dsum function, it should be
something like = but it doesn't make...
|
by: Newbie |
last post by:
how can i call an oracle function to get data without using a select
statement or stored procedures?
given a project_no, i need to call the function:
ops$sqltime.pa_new_job_no_fn
which will...
|
by: ckpoll2 |
last post by:
Hi,
I have made a report that has a query as its record source. I put a text box in there that I want to run a dsum function off of a different query. The criteria that I need to use is that it...
|
by: technocraze |
last post by:
Hi community experts,
I am having an isue with Dsum function that is used to count the total number for a particular field (intake) at the textbox afterupdate event with condition/ criteria...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |