473,395 Members | 1,343 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,395 software developers and data experts.

DSum function

76
Hello,

I'm trying to write a function that will sum the Hours column in the Credit Hours query for a user defined date range. This is the function that I have so far.

=DSum("[Hours]","Credit Hours","Date>=[Enter Start Date (MM/DD/YY)] And <=[Enter End Date (MM/DD/YY)]")

It seems like it should work, but I keep getting a #Error. What is wrong with my function? I have been pulling my hair out trying to figure this out.

Thanks,

Charlie
Dec 14 '06 #1
12 2453
MMcCarthy
14,534 Expert Mod 8TB
Hello,

I'm trying to write a function that will sum the Hours column in the Credit Hours query for a user defined date range. This is the function that I have so far.

=DSum("[Hours]","Credit Hours","Date>=[Enter Start Date (MM/DD/YY)] And <=[Enter End Date (MM/DD/YY)]")

It seems like it should work, but I keep getting a #Error. What is wrong with my function? I have been pulling my hair out trying to figure this out.

Thanks,

Charlie
Either of the following will work?

Expand|Select|Wrap|Line Numbers
  1.  
  2. =DSum("[Hours]","Credit Hours","[Date]>=#[Enter Start Date (MM/DD/YY)]# And [Date]<=#[Enter End Date (MM/DD/YY)]#")
  3.  
OR

Expand|Select|Wrap|Line Numbers
  1. =DSum("[Hours]","Credit Hours","[Date] BETWEEN #[Enter Start Date (MM/DD/YY)]# And #[Enter End Date (MM/DD/YY)]#")
  2.  
Mary
Dec 14 '06 #2
ckpoll2
76
Mary,

Thanks for the response and for looking into my problem. I tried both of those formulas and both gave me a #Error. Is there something I have to change in the text box characteristics? Also, I noticed the # signs in front and at the end of the [Enter] boxes. What they're entering isn't a number. Is there some kind of symbol that could represent a date rather than a number? Is there anything else I can do?

Thanks so much,

Charlie
Dec 14 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Hi Charlie

I know it doesn't make sense but # is the date representation in Access.

Rules:

String/Text - surround with single quotes
Date - surround with #
Number - no symbol required

You are summing the number of hours so the text box needs to be a number rather than a date/time format as Access cannot calculate in time beyond 24 hours. Once you have the number we can provide the formula to show the number of hours.

Are you being asked for the date parameters and did you enclose the date field in square brackets as per my example. In access Date is a function that returns the current date and you need to designate it as a field by enclosing it in square brackets. Ideally it would be a good idea to change the name of this field.

Mary


Mary,

Thanks for the response and for looking into my problem. I tried both of those formulas and both gave me a #Error. Is there something I have to change in the text box characteristics? Also, I noticed the # signs in front and at the end of the [Enter] boxes. What they're entering isn't a number. Is there some kind of symbol that could represent a date rather than a number? Is there anything else I can do?

Thanks so much,

Charlie
Dec 14 '06 #4
ckpoll2
76
I tried changing Date to TDate and used the same formula without the [] around it and that didn't work. Also, I don't know what you mean when you say once I have the number we can provide the formula to show the number of hours.

I copied and pasted the formula exactly from your post to the cell, so it appears as you typed it.

Is there any other way that you know of that I can accomplish this instead of going this route as it seems that this isn't wanting to work?

Charlie
Dec 14 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Did you change the data type of the textbox control to a number. Format as Single or double by the way.

Mary

I tried changing Date to TDate and used the same formula without the [] around it and that didn't work. Also, I don't know what you mean when you say once I have the number we can provide the formula to show the number of hours.

I copied and pasted the formula exactly from your post to the cell, so it appears as you typed it.

Is there any other way that you know of that I can accomplish this instead of going this route as it seems that this isn't wanting to work?

Charlie
Dec 14 '06 #6
ckpoll2
76
I set the format to "General Number". Is this what you mean? Also, I'm not sure I understand the single or double. I'm still a beginner at Access...
Dec 14 '06 #7
NeoPa
32,556 Expert Mod 16PB
Coming in here late I know, but Date variables don't need #s around them and a value passed by the operator (as you use) works like a variable.
Give me a second & I will post a version of your code for you.
Dec 14 '06 #8
NeoPa
32,556 Expert Mod 16PB
This is essentially Mary's version but without the delimiters.
Expand|Select|Wrap|Line Numbers
  1. =DSum("[Hours]","Credit Hours","[Date] Between [Enter Start Date (MM/DD/YY)] And [Enter End Date (MM/DD/YY)]")
Dec 14 '06 #9
NeoPa
32,556 Expert Mod 16PB
I've just updated the thread explaining all this to include this situation more clearly - (Literal DateTimes and Their Delimiters (#).). Have a look if you're interested.
Dec 14 '06 #10
ckpoll2
76
I really don't mean to keep crushing your ideas, but that one didn't work either. When you all are posting these formulas, are they working for you? I'm just trying to figure out if there's something that I'm doing wrong.

This is in a report and is in the report footer. Is that what is causing the problem?

Thank you for your continued support.
Dec 14 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Are you being asked for the date parameters ?


I have a feeling you can't enter parameters like this in a report footer.

Mary
Dec 15 '06 #12
NeoPa
32,556 Expert Mod 16PB
I really don't mean to keep crushing your ideas, but that one didn't work either. When you all are posting these formulas, are they working for you? I'm just trying to figure out if there's something that I'm doing wrong.

This is in a report and is in the report footer. Is that what is causing the problem?

Thank you for your continued support.
Charlie,

In almost all situations on here we are unable to reproduce the question on our machines. Mainly because too little information is provided but also many questions are determined by data or database setup which we simply don't have available to us without high levels of work. Such levels that would make answering the number of questions here completely impractical.
In some circumstances I do test the code I provide but they are rare.
So, in answer, it generally comes from the tops of our heads.

In this case, it would be helpful to know exactly how it failed and to see the code you actually tried. Sometimes we can see that members have not quite followed the answer when they post their code. Other times we know it's more complicated. It's rarely the latter.

I'm trying to write a function that will sum the Hours column in the Credit Hours query for a user defined date range. This is the function that I have so far.
I understood from this that you were working within a query. If that is not true and you are putting this calculation in your report footer, then I'm afraid that won't work for you.
To get around this you can add these two fields to you query and ignore them everywhere except in the report footer. This should give you the result you're after.
Dec 15 '06 #13

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

Similar topics

0
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success....
1
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...
2
by: Dalan | last post by:
I seemed to be having problems with structuring the use of NZ with a DSum expression. Having tried numerous variations of the expression without success, I'm asking for assistance. First some...
4
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...
3
by: Mark Reed | last post by:
All, I have never used this function before and am not sure it what I need. Just to clarify, I have a report based on a query which has amoungst other field, wk, parea & packs_req. What I am...
3
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...
1
by: Marc Aube | last post by:
Is there a web site that can ofer some help. The quotation marks are posing an issue as well as other items for this function. I have some books but they are not consistent in their use of the code...
3
patjones
by: patjones | last post by:
Good morning all: In what seems like an ongoing saga to make the DSum function do what I need it to, I am now having trouble with a user-defined function in my VBA module. Here's the offending...
2
jmoudy77
by: jmoudy77 | last post by:
Hi, I'm trying to use a variable "FirstSemi" as the second criteria in a DSum function. The DSum function is used in the same Form_Load function that the variable was declared. I keep getting an...
4
by: Adam1331 | last post by:
I've been trying to get the DSum function to work but I've been running into some roadblocks. What I'm trying to do is to total up times in a timesheet report into different departments. The report...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
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...
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
jinu1996
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...
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...

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.