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

Multiple SQL Select Statements or DLookup Function in the same Report

I have a Report that shows the following:

1) Name of Claim Processor
2) Total Claims Processed
3) Total Errors in Claims Processed

The criteria for the select query underlying the report is a date range (ProcessedDate) which is entered from a form that the end user accesses. This date range is typically for a month, for example 05/01/2013 through 05/31/2013.
Here is the issue I'm having trouble with, the user wants to see items 1, 2, and 3 above summarized by the WEEK in addition to a grand tally for the month (or whatever the date range is).

I have no problem getting the individual dates for each week within the month/date range, however, I can't figure out a way to dispay the grouping by week separately on the same report. Is it possible to have multiple text boxes with each text box's control source set to a different DLookup function or SQL Select query that restricts by the weekly dates? For example:

Week of 5/6/13 thru 5/10/13 Processor | #Claims | #Errors

Week of 5/13/13 thru 5/17/13 Processor | #Claims | #Errors

Week of 5/20/13 thru 5/24/13 Processor | #Claims | #Errors

Week of 5/27/13 thru 5/31/13 Processor | #Claims | #Errors

Thanks in advance for any ideas on how I can approach this!
Jun 24 '13 #1
7 1698
Rabbit
12,516 Expert Mod 8TB
You can use the Format() function to return the week number in the query and group by that. As for the monthly grand total, you can just put a sum at the end of the report since your date range is for a month anyways.
Jun 25 '13 #2
I think I'm pretty close to a solution on this but now I'm stuck on an expression.

So I went with a report based on a crosstab query that is structured like this:

Expand|Select|Wrap|Line Numbers
  1. Supervisor (Group by Row Heading)
  2.  | Manager (Group by Row Heading) | 
  3. Expression: DateAdd("d",1-Weekday([ProcessedDate],2),[ProcessedDate]) 
  4. Group by Column Heading | 
  5. CountofClaims Sum of Value | 
  6. TotalCount of Claims Sum of Row Heading
The part giving me problems is the expression:
Expand|Select|Wrap|Line Numbers
  1. DateAdd("d",1-Weekday([ProcessedDate],2),[ProcessedDate])
That expression will return the date of the Monday before Sunday. So weeks
run from Monday to Sunday. How do I make the week run from Monday to Friday only? I am trying to sum by week for weekdays the # of claims done by processer by supervisor and manager. For example, I know the week of 5/13/13 (Monday) thru 5/17/13 (Friday) a particular processor completed 40 claims, however, using this function, it shows that the processor completed 50 claims for the week of 5/13/13. Others processors show 60 per week, when it should be no more than 50.

I am so close on this and would really appreciate any help on the expression syntax, thank you!
Jun 27 '13 #3
Rabbit
12,516 Expert Mod 8TB
It would be more helpful to see the SQL.

As far as the date range goes, if you can get the sunday, then getting the friday is merely subtracting two days from sunday.
Jun 27 '13 #4
Here is the SQL code...

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(Qry_QSRWeeklyRpt_NCDev_Step2.CountOfUpdater) AS SumOfCountOfUpdater
  2. SELECT Qry_QSRWeeklyRpt_NCDev_Step2.Updater, Qry_QSRWeeklyRpt_NCDev_Step2.tmm_last_name, Qry_QSRWeeklyRpt_NCDev_Step2.tmm_first_name, Qry_QSRWeeklyRpt_NCDev_Step2.Supervisor, Qry_QSRWeeklyRpt_NCDev_Step2.Manager, Sum(Qry_QSRWeeklyRpt_NCDev_Step2.CountOfUpdater) AS [Total Of CountOfUpdater]
  3. FROM Qry_QSRWeeklyRpt_NCDev_Step2
  4. GROUP BY Qry_QSRWeeklyRpt_NCDev_Step2.Updater, Qry_QSRWeeklyRpt_NCDev_Step2.tmm_last_name, Qry_QSRWeeklyRpt_NCDev_Step2.tmm_first_name, Qry_QSRWeeklyRpt_NCDev_Step2.Supervisor, Qry_QSRWeeklyRpt_NCDev_Step2.Manager
  5. PIVOT DateAdd("d",1-Weekday([ProcessedDate],2),[ProcessedDate]);
  6.  
Updater is the Claims Processor and CountofUpdater is the total # of claims processed.

I guess my question is that I don't really understand how to get the start and the end day for the DateAdd function and still display the week starting date as the column heading. I know it's probably really simple but I'm still stumped.
Jun 27 '13 #5
Rabbit
12,516 Expert Mod 8TB
If you want to append two strings, you can use the & operator. For example:
"cat " & "dog"
Will return:
cat dog
Jun 27 '13 #6
Yay! I figured it out:

To exclude Sat and Sun records I calculated another field for the day of week and applied filter criteria:

Expand|Select|Wrap|Line Numbers
  1. DayOfWeek: Format([ProcessedDate],"ddd")
  2.  
  3. <> "Sat" And <> "Sun" 
Jun 27 '13 #7
Rabbit
12,516 Expert Mod 8TB
Glad you got it working. Good luck with the rest of your project!
Jun 27 '13 #8

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

Similar topics

0
by: jamiemcc | last post by:
Hi, I would like to have 1 stored procedure call another stored procedure (which contains multiple select statements) and then be able to access the 3 result sets. Example Create Procedure ....
1
by: Harry V | last post by:
I'm wondering if there is a limit of a single select, delete and insert statement (command) to each dataadapter? On a form, I have a dataconnection that is shared by 3 dataadapters, one for each of...
3
by: Joe via DotNetMonster.com | last post by:
Hi, I'm trying to use several select statements so that I don't need to call the function several times. The next Result set always seems to read the first select statement. I have the...
2
by: jonvan20 | last post by:
I have been having trouble with a simple Dlookup command that was Reccommended to me by a nice fellow named Vic, On the other hand I have statements like this that wont run they give me a run time...
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have coded multiple select statements in a single stored procedure, and when I execute this procedure on SQL Server Management Express, I correctly get multiple result sets. But, if I try to add...
0
by: musman | last post by:
hey all, I have tried to use the select statement instead DLookUp function as i have sql server at my backend and access as my front end. But neither DLookUp function is working nor select state...
4
by: vertigo262 | last post by:
Is it possible to use to select statements in a stored procedure? I am building a movie rating system, what I am doing is creating a table with movies and individual user ratings. The code...
7
by: golffor1 | last post by:
Hello I was wondering if you could help me out with doing multiple select statements. I have this objCommand.CommandText = "Select * from table" objCommand.CommandText1 = "Select * from...
3
by: els12 | last post by:
How do I write 2 distinct select queries in one sql statement, and then also divide the results of one by the other? The first query will give me a subset of all the records in the table...the...
11
by: pattyd | last post by:
I have multiple queries that will run on my onopen event of my report. I use the docmd.openquery for the select queries the problem is I can see all these popup in the background. I do use the close...
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: 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
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
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...

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.