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

Report to pull data from different tables

Hi Everyone : )

I hope that this question is actually something easy in disguise. Re: Access 2003 I have a report that displays information about which of our employees worked at a given job over a period of 2 weeks, and displays how much we paid them for their work at that job (using DSUM to calc all those records within that 2 week period). This works just fine.

The problem is that sometimes our guys work at these little side jobs. For a long list of reasons, we've decided to track these jobs separately and in another table. The report needs to show the following:

Employee JobName ContractCost SideJobCost
(labor table) (labor table) (dsum from labor) (dsum from extrajobs)

The WHERE statement on the contract and sidejob costs say "WHERE [employee] = employee.value AND [jobname] = jobname.value". So I'm saying to pull a list of everything they worked at for a 2 week period, then DSUM all the values to get one cohesive entry. This works fine except on certain occasions for the SideJobCost.

Consider this. Employee A works 8 hours doing a sidejob (found in another table) but he never works at this job, in that period, in the Labor table. So the report will only be able to DSUM the calculations for jobs that it CAN find in the report (which is pulling from the labor table, not the 'extrajobs' table), because I'm querying the values that are displayed in the report.

I hope this isn't confusing lol What I ultimately want is to be able to tell the report to say "Find all the jobs that people have worked at on both the labor table, and the extrajobs table" and DSUM the values to create a total.

Anyone with any info would be a tremendous help. It sounds easy enough but I can't figure this out : (

-Cathy
Dec 12 '07 #1
6 3490
puppydogbuddy
1,923 Expert 1GB
Hi Everyone : )

I hope that this question is actually something easy in disguise. Re: Access 2003 I have a report that displays information about which of our employees worked at a given job over a period of 2 weeks, and displays how much we paid them for their work at that job (using DSUM to calc all those records within that 2 week period). This works just fine.

The problem is that sometimes our guys work at these little side jobs. For a long list of reasons, we've decided to track these jobs separately and in another table. The report needs to show the following:

Employee JobName ContractCost SideJobCost
(labor table) (labor table) (dsum from labor) (dsum from extrajobs)

The WHERE statement on the contract and sidejob costs say "WHERE [employee] = employee.value AND [jobname] = jobname.value". So I'm saying to pull a list of everything they worked at for a 2 week period, then DSUM all the values to get one cohesive entry. This works fine except on certain occasions for the SideJobCost.

Consider this. Employee A works 8 hours doing a sidejob (found in another table) but he never works at this job, in that period, in the Labor table. So the report will only be able to DSUM the calculations for jobs that it CAN find in the report (which is pulling from the labor table, not the 'extrajobs' table), because I'm querying the values that are displayed in the report.

I hope this isn't confusing lol What I ultimately want is to be able to tell the report to say "Find all the jobs that people have worked at on both the labor table, and the extrajobs table" and DSUM the values to create a total.

Anyone with any info would be a tremendous help. It sounds easy enough but I can't figure this out : (

-Cathy
It seems like all you need to do is wrap the null to zero function around ContractCost and around SideJobCost. That way, if one or the other is null, the appropriate cost column will show 0, which will calculate correctly in the DSum.

nz([ContractCost],0) nz([SideJobCost],0)
Dec 12 '07 #2
NeoPa
32,556 Expert Mod 16PB
I'm more interested in the FROM clause of your SQL (JOIN types etc). Perhaps you could post all the SQL and we can see if there's anything there that might be complicating the task.
Dec 12 '07 #3
I guess I was being a bit unclear with my last post : ( I do use NZ to prevent null values in all of my reporting. The problem that I'm having is that if an employee works doing only those "extra jobs" and none of the "regular jobs" then the report won't find it.

So here's how the report is reading the code: 1) Report opens up and OnOpen it changes the recordsource to one of several queries (all relatively similar) 2) The report now fills in data to the textboxes (I'm not displaying the exact SQL, this is just to give an idea):

Employee || JobName || Normal Cost || Special Cost
(from labor tbl) || (from labor tbl) || (DSUM) || (DSUM)

In each of the DSUM arguments I'm querying, I'm saying =DSum("NormalCost","LaborQuery","[Employee] = employeename.value AND [jobName]=Job.value") The variables may be slightly different but you get the idea, I'm just telling the report to dsum all values from everything it finds in the report (from the LaborQuery).

So the problem is where I get to the Special Cost, because that data is located in another table, I change the DSUM "FROM" argument to reflect that other table. But I still need to specify the WHERE argument, this is where things get problematic. The "Special Cost" WHERE argument is still trying to query based off the information provided on the report by saying [JobName] = job.value but if the employee never worked anywhere (in that time frame) on the Labor table...it wont find anything to query so it will be omitted. Does that make sense?

NeoPa, you might be right about the JOIN properties. When I tried to join the tables on the query, the query returned 0 results every single time (not for any reason I could determine), so I assumed that I did something wrong and hoped that there was just another way to do this. I WOULD LIKE to be able to have the EmployeeName and JobName fields populate based off of the criteria from BOTH tables, that would solve my problem completely but I can't seem to get it to work.

Thanks guys : )

-Cathy
Dec 12 '07 #4
NeoPa
32,556 Expert Mod 16PB
...
NeoPa, you might be right about the JOIN properties. When I tried to join the tables on the query, the query returned 0 results every single time (not for any reason I could determine), so I assumed that I did something wrong and hoped that there was just another way to do this. I WOULD LIKE to be able to have the EmployeeName and JobName fields populate based off of the criteria from BOTH tables, that would solve my problem completely but I can't seem to get it to work.
...
Cathy, I can only help with the JOIN if I get to see it :S
A lot of the restrictions of records are actually in the FROM clause (on top of those in the WHERE clause).
Dec 12 '07 #5
Cathy, I can only help with the JOIN if I get to see it :S
A lot of the restrictions of records are actually in the FROM clause (on top of those in the WHERE clause).
NeoPa, if my F-E database weren't 75+Mb I'd gladly upload it and have you look at it lol What did you mean by the FROM clause? Is it possible to DSUM from two separate tables/queries? If so, that solves my problem right there : )

Are there any examples of this? I looked on thescripts.com before I posted this plea for help but I wasn't able to find anything that was similar or somehow related.
Dec 12 '07 #6
NeoPa
32,556 Expert Mod 16PB
What's the record source of the report?
It's basically the SQL of that that I'm talking about. I'm assuming it's going to be relatively uncomplicated. If not then it may be a show-stopper.
Big databases are fine - except no-one ever seems able to tell you where the problem actually is so you have to hunt forever before even finding the problem.

As a general rule (there are situations where this won't apply) it's best to populate the data within a report from a single recordset (Table; query; etc) which can be made up from various tables.

Let me know if this is practicable.`
Dec 12 '07 #7

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

Similar topics

5
by: cvillard | last post by:
I am new to SQL, as old as it is. I am not new to programming I normally just use Access. I have two tables for a little project manager I made. After updates I sent an email to the user. I need...
7
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables....
10
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
2
by: Jeremy Dillinger | last post by:
I have a program setup to pull data from a database. My database table has things such as (category, Item, price, etc.) In my program I want to have multiple list boxes that will have a pull down...
2
by: rinmanb70 | last post by:
I have a table that contains transaction info including the date of the trans and the date of the order. Some orders do not have a transaction date yet. I'd like to have a report that shows two...
0
by: Jerms | last post by:
Hello all, I've been using this site quite a bit since starting my project and have found it very helpful. I have run into a roadblock though that I cant seem to scrounge up a solution to. I...
7
by: baool | last post by:
I have a report that keeps track of sales by company for any given month within a year. I am using two subreports embedded within a report to produce 2006 (one subreport) and 2007 (the other...
3
by: nsymiakakis | last post by:
Hi everyone, I am hoping you can help me on this problem. I created 3 queries, each gives me a grand total Sum from various fields in 2 different tables. This part works great. Now I am trying to...
0
by: mbedford | last post by:
I'm buildling a form for tracking printer costs. This form will display data from several different tables pulled together by queries. formPrintCost will display: printer information from...
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: 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...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.