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

Need help forming a query

1,287 Expert 1GB
I need a query to see who worked what hours on activities, and I have combo boxes to narrow the results to a specific activity or employee. I can't figure out how to get the sums of different types of hours into the same row.
I had a query that went through every activity and did DSUMs for each category, but it was so slow and messy I had to trash it.

I have a table EmployeeHours with fields
PayPeriod - number
EmployeeNumber - text
ProjectNumber - text
ActivityNumber - text
ActivityTitle - text
HoursType - text
Hours - number

I need a query for a souce for a continuous form with:
project number, activity number, activity title, employee number, sumOfHours where HoursType is RG(regular), sumOfHours where HoursType is OS(overtime), sumOfHours where HoursType is (Anything Else).

Is that possible in one query?

Thanks for any help,
Chip
Dec 23 '08 #1
6 1399
FishVal
2,653 Expert 2GB
Hello, Chipr.

I guess you want the query to be updateable.
If so, then you need:
  • 1. Updateable query returning EmployeeNumber/ProjectNumber/ActivityNumber combinations to calculate totals on
  • 2. Add calculate fields to the query returning required totals.
  • 3. For these calculated fields you could conviniently use VBA function(s) written in such a way that it gets EmployeeNumber/ProjectNumber/ActivityNumber as arguments and returns correspondent total.
Dec 23 '08 #2
ChipR
1,287 Expert 1GB
Hi FishVal, thanks for your help.
Is there a faster way to do it if I don't need to update the results? I only need it for viewing.
Dec 23 '08 #3
FishVal
2,653 Expert 2GB
Sure.

Two aggregate queries grouping results by EmployeeNumber/ProjectNumber/ActivityNumber combinations - one to calculate overtime total, another to calculate the rest.
Then simply join them on equal values of EmployeeNumber/ProjectNumber/ActivityNumber fields.
Dec 23 '08 #4
ChipR
1,287 Expert 1GB
I tried that but it resulted in only the rows in the results of one query or the other, depending on the direction of the JOIN. Is there a way I can get all of them?
Dec 23 '08 #5
ChipR
1,287 Expert 1GB
I made a query with the cartesian product of all employees and all activities, joined it with the aggregate queries, and added a Total field: 0+nz(OS,0)+nz(RG,0)+nz(DT,0) where >0 to eliminate the activity+employee rows where there were no hours at all.
Now it's instantaneous compared to the several seconds it took before! Thanks for the help.
Dec 23 '08 #6
FishVal
2,653 Expert 2GB
You are welcome.
Good luck.
Dec 23 '08 #7

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

Similar topics

3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
1
by: web1110 | last post by:
Hi y'all, I am playing with some initial ideas for a system. What I want to do is maintain classes on a central server and instantiate them as needed on client machines. Essentially, changing...
3
by: Jon Maz | last post by:
Hi, A quick one: If you are forming a dynamic sql statement using parameters from a web form, you would normally double up any single inverted commas inputted by the user to stop sql...
10
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only...
6
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description:...
7
by: anonymous | last post by:
I need a help with forming a query for the following table.. Customerid Amnt Mode 1 200 Internet 2 100 ...
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
2
by: lamoureternal | last post by:
Hi everyone, I really need your help in this... I have a remote xml that resides on a URI like this "http://www.server.com/xmlFile.xml" The structure of the xml is heirarchical forming 1:M...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
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: 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$) { } ...
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: 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...

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.