Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Dynamic crosstab query with multiple values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DMUM - 19 Jan 2006 22:08 GMT
Hello

I have a table that shows the following information

intJobControlID
JobControlName
Defect
Opps
Sigma
DPMO

I needed to create a report that shows all of the fields for each JobName/ID
by month.  In order to do this I created 4 seperate crosstab queries for each
field - Defect, opps,SIGMA and DPMO.  Each query looks like this with the
only difference being SUM(tblMetricScorecard.field) AS Sumoffield

TRANSFORM Sum(tblMetricScorecard.dblDefects) AS SumOfdblDefects
SELECT tblMetricJobsAndControls.intJobControlID, tblMetricJobsAndControls.
JobControlName
FROM tblMetricJobsAndControls LEFT JOIN tblMetricScorecard ON
tblMetricJobsAndControls.intJobControlID = tblMetricScorecard.intJobControlID
GROUP BY tblMetricJobsAndControls.intJobControlID, tblMetricJobsAndControls.
JobControlName
PIVOT tblMetricScorecard.MetricMonthStamp;

To create the report - I created another query joining all 4 queries by the
JobNameID which works like a dream when creating this manually.  However I
have to manually go into the joined query and choose what months I want to
view form each individual query.  To create my final result, I must know what
Month(s) I want to include AND more importantly what MONTHS of data I have.

This is where my problem starts.  I want to create this report dynamicly -
allowing the user to choose what dates they want to see.  I tried doing this
by having the individual queries correspond to a getStartDate and getEndDate
function on a form that will open when the user chooses to run this
partivular report.  This part works, but when I get to the JOIN of the 4
queries, I'm at a lost as to how to dynamically have the correct months
populate the JOIN query.

This is my JOIN query:

SELECT qry_RT_Defect_CT.intJobControlID, qry_RT_Opps_CT.JobControlName,
qry_RT_Defect_CT.[200501] AS JanDefect, qry_RT_Defect_CT.[200502] AS
FebDefect, qry_RT_Defect_CT.[200503] AS MarDefect, qry_RT_Defect_CT.[200504]
AS AprDefect, qry_RT_Defect_CT.[200505] AS MayDefect, qry_RT_Defect_CT.
[200506] AS JunDefect, qry_RT_Defect_CT.[200507] AS JulDefect,
qry_RT_Defect_CT.[200508] AS AugDefect, qry_RT_Defect_CT.[200509] AS
SepDefect, qry_RT_Defect_CT.[200510] AS OctDefect, qry_RT_Opps_CT.[200501] AS
JanOpps, qry_RT_Opps_CT.[200502] AS FebOpps, qry_RT_Opps_CT.[200503] AS
MarOpps, qry_RT_Opps_CT.[200504] AS AprOpps, qry_RT_Opps_CT.[200505] AS
MayOpps, qry_RT_Opps_CT.[200506] AS JunOpps, qry_RT_Opps_CT.[200507] AS
JulOpps, qry_RT_Opps_CT.[200508] AS AugOpps, qry_RT_Opps_CT.[200509] AS
SepOpps, qry_RT_Opps_CT.[200510] AS OctOpps, qry_RT_Sigma_CT.[200501] AS
JanSigma, qry_RT_Sigma_CT.[200502] AS FebSigma, qry_RT_Sigma_CT.[200503] AS
MarSigma, qry_RT_Sigma_CT.[200504] AS AprSigma, qry_RT_Sigma_CT.[200505] AS
MaySigma, qry_RT_Sigma_CT.[200506] AS JunSigma, qry_RT_Sigma_CT.[200507] AS
JulSigma, qry_RT_Sigma_CT.[200508] AS AugSigma, qry_RT_Sigma_CT.[200509] AS
SepSigma, qry_RT_Sigma_CT.[200510] AS OctSigma, qry_RT_DPMO_CT.[200501] AS
JanDPMO, qry_RT_DPMO_CT.[200502] AS FebDPMO, qry_RT_DPMO_CT.[200503] AS
MarDPMO, qry_RT_DPMO_CT.[200504] AS AprDPMO, qry_RT_DPMO_CT.[200505] AS
MayDPMO, qry_RT_DPMO_CT.[200506] AS JunDPMO, qry_RT_DPMO_CT.[200507] AS
JulDPMO, qry_RT_DPMO_CT.[200508] AS AugDPMO, qry_RT_DPMO_CT.[200509] AS
SepDPMO, qry_RT_DPMO_CT.[200510] AS OctDPMO
FROM ((qry_RT_Defect_CT INNER JOIN qry_RT_Opps_CT ON qry_RT_Defect_CT.
JobControlName = qry_RT_Opps_CT.JobControlName) INNER JOIN qry_RT_Sigma_CT ON
qry_RT_Opps_CT.JobControlName = qry_RT_Sigma_CT.JobControlName) INNER JOIN
qry_RT_DPMO_CT ON qry_RT_Sigma_CT.JobControlName = qry_RT_DPMO_CT.
JobControlName;

The problem here is that If I need to add Novembers data - I have to manually
go in and add it to each individual query and then add it to the JOIN query.
Also, if I don't have data - say for JUN, I get an error because the JOIN
query is looking for that month  

I've looked at many of the responses for crosstab queries and also looked at
a few examples that were provided.  But, I don't see any that represent what
I need or either I am just not understanding the recommendation provided -
this is of course not a far fetched idea.  Anyway, I would appreciate any
help someone can provide.  I am a loss how to get this to work without a
manual change.

Thank you
Duane Hookom - 20 Jan 2006 03:47 GMT
I'm not sure what all you need but this google groups search string might
help you find a solution
  Mth1 group:*Access.Reports* author:hookom
Also, check these crosstab report solutions at
http://www.invisibleinc.com/divFiles.cfm?divDivID=4

Signature

Duane Hookom
MS Access MVP
--

> Hello
>
[quoted text clipped - 98 lines]
>
> Thank you
DMUM - 20 Jan 2006 15:59 GMT
Hi Duane

I looked at this already.  Unfortuneatly it doesn't help me do what I need.
Is there any additional information that I can provide that can help me
explain my problem?  I really need help on this and I'm sure there is a way
to do it, just not clear how.

Thanks

>I'm not sure what all you need but this google groups search string might
>help you find a solution
[quoted text clipped - 7 lines]
>>
>> Thank you
Duane Hookom - 20 Jan 2006 22:20 GMT
Ok, try Google Groups with this search
  multi value crosstab group:*access.queries* author:hookom
Try the first link...

Signature

Duane Hookom
MS Access MVP
--

> Hi Duane
>
[quoted text clipped - 18 lines]
>>>
>>> Thank you
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.