PC Review


Reply
Thread Tools Rate Thread

Crosstab Report's subreport

 
 
Joseph
Guest
Posts: n/a
 
      15th Apr 2010
I have a report based on the following code:

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open

Dim dStart, DayOne, DayTwo, DayThree, DayFour, DayFive, DaySix, DaySeven
As Variant
Dim stSql String

dStart = Forms!PrintReport.Friday

DayOne = dStart
DayTwo = DateAdd("d", 1, DayOne)
DayThree = DateAdd("d", 2, DayOne)
DayFour = DateAdd("d", 3, DayOne)
DayFive = DateAdd("d", 4, DayOne)
DaySix = DateAdd("d", 5, DayOne)
DaySeven = DateAdd("d", 6, DayOne)

stSql = "TRANSFORM Max(MeritsMain2Total.Total) AS MaxOfTotal SELECT
Cadets.CadetID, MeritsMain2Total.CadetName, Phase.Phase, Dorms.Dorm FROM
Dorms INNER JOIN ((Phase INNER JOIN (CadetsName INNER JOIN Cadets ON
CadetsName.CadetID = Cadets.CadetID) ON Phase.PhaseID = Cadets.PhaseID) INNER
JOIN MeritsMain2Total ON Cadets.CadetID = MeritsMain2Total.CadetID) ON
(Dorms.DormID = CadetsName.DormID) AND (Dorms.DormID = Cadets.DormID) GROUP
BY Cadets.CadetID, MeritsMain2Total.CadetName, Phase.Phase, Dorms.Dorm PIVOT
Format([DTGofMerits],'Short Date') In ('" & DayOne & "','" & DayTwo & "','" &
DayThree & "','" & DayFour & "','" & DayFive & "','" & DaySix & "','" &
DaySeven & "');"
Me.RecordSource = stSql

Me.DayOne.ControlSource = DayOne
Me.DayOneLabel.Caption = DayOne
Me.DayTwo.ControlSource = DayTwo
Me.DayTwoLabel.Caption = DayTwo
Me.DayThree.ControlSource = DayThree
Me.DayThreeLabel.Caption = DayThree
Me.DayFour.ControlSource = DayFour
Me.DayFourLabel.Caption = DayFour
Me.DayFive.ControlSource = DayFive
Me.DayFiveLabel.Caption = DayFive
Me.DaySix.ControlSource = DaySix
Me.DaySixLabel.Caption = DaySix
Me.DaySeven.ControlSource = DaySeven
Me.DaySevenLabel.Caption = DaySeven

End_Report_Open:
Exit Sub

Err_Report_Open:
MsgBox Err.Description
Resume End_Report_Open

End Sub

And believe it or not, it works. The report is based on a saved crosstab,
but I wanted to limit the fields dynamically. I also have a subreport that
is based on a saved query("SELECT DISTINCTROW CadetAwards.CadetID,
AwardType.Abbrev, Count(CadetAwards.AwardType) AS CountOfAwardType
FROM CadetAwards INNER JOIN AwardType ON CadetAwards.AwardType =
AwardType.AwardType
GROUP BY CadetAwards.CadetID, AwardType.Abbrev, AwardType.AwardType
HAVING (((([AwardType].[AwardType])=6 Xor
([AwardType].[AwardType])>=10)<>False));"). Now I thought that I could just
easily set the link fields to show linked information (CadetID->CadetID), but
when I run the report, the subreport does not show any information.

How do I get the subreport to show? I understand that if there is not data
to show that it should be blank, but there is data.



 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      16th Apr 2010
It looks like you might have a crosstab that uses a week of dates as columns
headings. If this is the case, I think the solution at
http://www.tek-tips.com/faqs.cfm?fid=5466 is much more efficient and simpler
(no code required). It should work well as a subreport without having to
change any Record Sources.


--
Duane Hookom
MS Access MVP


"Joseph" <(E-Mail Removed)> wrote in message
news:012D751A-CB0D-4489-A82C-(E-Mail Removed)...
> I have a report based on the following code:
>
> Private Sub Report_Open(Cancel As Integer)
> On Error GoTo Err_Report_Open
>
> Dim dStart, DayOne, DayTwo, DayThree, DayFour, DayFive, DaySix,
> DaySeven
> As Variant
> Dim stSql String
>
> dStart = Forms!PrintReport.Friday
>
> DayOne = dStart
> DayTwo = DateAdd("d", 1, DayOne)
> DayThree = DateAdd("d", 2, DayOne)
> DayFour = DateAdd("d", 3, DayOne)
> DayFive = DateAdd("d", 4, DayOne)
> DaySix = DateAdd("d", 5, DayOne)
> DaySeven = DateAdd("d", 6, DayOne)
>
> stSql = "TRANSFORM Max(MeritsMain2Total.Total) AS MaxOfTotal SELECT
> Cadets.CadetID, MeritsMain2Total.CadetName, Phase.Phase, Dorms.Dorm FROM
> Dorms INNER JOIN ((Phase INNER JOIN (CadetsName INNER JOIN Cadets ON
> CadetsName.CadetID = Cadets.CadetID) ON Phase.PhaseID = Cadets.PhaseID)
> INNER
> JOIN MeritsMain2Total ON Cadets.CadetID = MeritsMain2Total.CadetID) ON
> (Dorms.DormID = CadetsName.DormID) AND (Dorms.DormID = Cadets.DormID)
> GROUP
> BY Cadets.CadetID, MeritsMain2Total.CadetName, Phase.Phase, Dorms.Dorm
> PIVOT
> Format([DTGofMerits],'Short Date') In ('" & DayOne & "','" & DayTwo &
> "','" &
> DayThree & "','" & DayFour & "','" & DayFive & "','" & DaySix & "','" &
> DaySeven & "');"
> Me.RecordSource = stSql
>
> Me.DayOne.ControlSource = DayOne
> Me.DayOneLabel.Caption = DayOne
> Me.DayTwo.ControlSource = DayTwo
> Me.DayTwoLabel.Caption = DayTwo
> Me.DayThree.ControlSource = DayThree
> Me.DayThreeLabel.Caption = DayThree
> Me.DayFour.ControlSource = DayFour
> Me.DayFourLabel.Caption = DayFour
> Me.DayFive.ControlSource = DayFive
> Me.DayFiveLabel.Caption = DayFive
> Me.DaySix.ControlSource = DaySix
> Me.DaySixLabel.Caption = DaySix
> Me.DaySeven.ControlSource = DaySeven
> Me.DaySevenLabel.Caption = DaySeven
>
> End_Report_Open:
> Exit Sub
>
> Err_Report_Open:
> MsgBox Err.Description
> Resume End_Report_Open
>
> End Sub
>
> And believe it or not, it works. The report is based on a saved crosstab,
> but I wanted to limit the fields dynamically. I also have a subreport
> that
> is based on a saved query("SELECT DISTINCTROW CadetAwards.CadetID,
> AwardType.Abbrev, Count(CadetAwards.AwardType) AS CountOfAwardType
> FROM CadetAwards INNER JOIN AwardType ON CadetAwards.AwardType =
> AwardType.AwardType
> GROUP BY CadetAwards.CadetID, AwardType.Abbrev, AwardType.AwardType
> HAVING (((([AwardType].[AwardType])=6 Xor
> ([AwardType].[AwardType])>=10)<>False));"). Now I thought that I could
> just
> easily set the link fields to show linked information (CadetID->CadetID),
> but
> when I run the report, the subreport does not show any information.
>
> How do I get the subreport to show? I understand that if there is not
> data
> to show that it should be blank, but there is data.
>
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
report using a subreport based on a crosstab query Nona Microsoft Access 5 2nd Feb 2010 03:14 PM
Re: Hide subreport and main report record if subreport running sum is zero Marshall Barton Microsoft Access Reports 4 17th Nov 2009 06:08 PM
Report w/subreport; Subreport not displaying related records =?Utf-8?B?TGVpZ2h0b24uZA==?= Microsoft Access Reports 4 17th Mar 2007 04:15 PM
Reference Main Report Crosstab Query from Subreport blinton25 Microsoft Access Reports 0 7th Jun 2004 11:42 PM
Crystal Report with SubReport, SubReport prints on separate page Tim Frawley Microsoft VB .NET 1 1st Nov 2003 01:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:08 PM.