473,397 Members | 2,116 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,397 software developers and data experts.

Problems with DSum criteria

patjones
931 Expert 512MB
Hi:

This is sort of the second part to an earlier question I asked about summing. It's pretty simple. My code is:

Expand|Select|Wrap|Line Numbers
  1. Me!txtLostDaysNoPaySeasonal = DSum("DateDiff('d', [tblWC]![fldDateOfNoPayBegin], [tblWC]![fldDateReturned])", "tblWC", "[fldPayDistCode] = 'BK21312'")
In other words, it's supposed to take the difference in dates for each record, then sum that difference over all records that match the criteria. The result goes in a locked text box on my main form.

Instead, I get an error that says The expression you entered as a query parameter produced this error: '[fldPayDistCode]'

This is the exact syntax shown in the Access help pages from MS, but it's not working for me. Any ideas?

Pat
Sep 19 '07 #1
3 3252
patjones
931 Expert 512MB
Hi:

This is sort of the second part to an earlier question I asked about summing. It's pretty simple. My code is:

Expand|Select|Wrap|Line Numbers
  1. Me!txtLostDaysNoPaySeasonal = DSum("DateDiff('d', [tblWC]![fldDateOfNoPayBegin], [tblWC]![fldDateReturned])", "tblWC", "[fldPayDistCode] = 'BK21312'")
In other words, it's supposed to take the difference in dates for each record, then sum that difference over all records that match the criteria. The result goes in a locked text box on my main form.

Instead, I get an error that says The expression you entered as a query parameter produced this error: '[fldPayDistCode]'

This is the exact syntax shown in the Access help pages from MS, but it's not working for me. Any ideas?

Pat
OK, well I figured out the problem...[fldPayDistCode] resides in tblEmployees, not tblWC. But that presents another problem. tblWC and tblEmployees are connected via a one-to-many relationship through the field "fldERN" (that's Employee Reference Number for short). However, I want to pick out records in tblWC based on criteria for fldPayDistCode which which doesn't have anything to do with fldERN except that they are in the same table.

Can I still do this via the DSum function?
Sep 19 '07 #2
patjones
931 Expert 512MB
OK, well I figured out the problem...[fldPayDistCode] resides in tblEmployees, not tblWC. But that presents another problem. tblWC and tblEmployees are connected via a one-to-many relationship through the field "fldERN" (that's Employee Reference Number for short). However, I want to pick out records in tblWC based on criteria for fldPayDistCode which which doesn't have anything to do with fldERN except that they are in the same table.

Can I still do this via the DSum function?
Figured this one out also. I simply built a query called "qryTest" which picks out [tblEmployees]![fldPayDistCode] = "BK21312" and then based the DSum function on that query:

Expand|Select|Wrap|Line Numbers
  1. DSum("DateDiff('d', [tblWC]![fldDateOfNoPayBegin], [tblWC]![fldDateReturned])", "qryTest")
I hope this helps other people at least! : - )
Sep 19 '07 #3
mlcampeau
296 Expert 100+
I'm glad you got it to work! Sorry none of the "Experts" got around to answering your question before you figured it out. Thanks for posting your results for other members to see.
Sep 19 '07 #4

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

Similar topics

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...
4
by: John Baker | last post by:
Hi: At the bottom of a report, I wish to sum all the amounts that appear in a field called Discount$ that appears on the report. I am not doing this summing in the query that supports the report...
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...
8
by: deercreek | last post by:
I have the following table test3. RESERVATIONID Site SitePrice 101 RV2 $25.00 101 RV3 $25.00 102 RV4 $25.00 102 RV5 $25.00 104 ...
3
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
3
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...
33
by: potassium flower | last post by:
I am trying to create a food order system for a restaurant. I have tried using both the DSum and Sum functions to calculate the total cost of an order. The total cost is a textbox on the form...
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...
3
by: majapa | last post by:
To start, here is my DSum expression: Develop: Nz(DSum(". & "] + . & "]","CSO","='Ability to Develop'")*-1,0) I actually have 4 of these, each one with a different option for . For more context,...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.