J
john
I am in access 2002 and HAVE REPORT BASED ON QUERY:
I have report layout like:
In header area: there are 6 control Total1,
Total2.... Total6
In Detail ares: there are controls: dTotal1.......
dTotal6 and dPer1.......dPer6.
When run the report. The header ares print OK. But All
controls in Detail Areas Print something: #name?. I know
it does not find reference. As you see my code, The both
reference to the same query return fields. I do not know
why in header's areas controls' controlsource can see the
query return fields and in detail areas can not see them?
the code is here:
Query: (run fine.)
TRANSFORM Round(Sum(amr_diag03s1.Vol_SIX_06_2003)) AS
[Sum]
SELECT Modal, market, Round(Sum
(amr_diag03s1.Vol_SIX_06_2003)) AS Total
FROM amr_diag03s1
WHERE marketer<>"@unknown"
GROUP BY Modal, market
PIVOT Marketer In ('Company 1','Company 2','Company
3','Company 4');
Code: (detail area print #name? on all controls)
private sub report_open()
setLayout
end sub
Private Sub setLayout()
Dim strRecordSource As String
Me.RecordSource = above query
Me.Controls("Modal").ControlSource = "[Modal]+
[Record_type]+[Market]"
'Detail Area controls
Me.Controls("dTotal1").ControlSource = "[Company 1]"
Me.Controls("dTotal2").ControlSource = "[Company 2]"
Me.Controls("dTotal3").ControlSource = "[Company 3]"
Me.Controls("dTotal4").ControlSource = "[Company 4]"
Me.Controls("dTotal5").ControlSource = "[Total]-
[Company 1]-[Company 2]-[Company 3]-[Company 4]"
Me.Controls("dTotal6").ControlSource = "[Total]"
Me.Controls("dPer1").ControlSource = "[Company 1]"
Me.Controls("dPer2").ControlSource = "[Company 2]"
Me.Controls("dPer3").ControlSource = "[Company 3]"
Me.Controls("dPer4").ControlSource = "[Company 4]"
Me.Controls("dPer5").ControlSource = "[Total]-[Company
1]-[Company 2]-[Company 3]-[Company 4]"
Me.Controls("dPer6").ControlSource = "[Total]"
'Header Areas
Me.Controls("Total1").ControlSource = "=sum([Company
1])"
Me.Controls("Total2").ControlSource = "=sum([Company
2])"
Me.Controls("Total3").ControlSource = "=sum([Company
3])"
Me.Controls("Total4").ControlSource = "=sum([Company
4])"
Me.Controls("Total5").ControlSource = "=sum([Total]-
[Company 1]-[Company 2]-[Company 3]-[Company 4])"
Me.Controls("Total6").ControlSource = "=sum([TOTAL])"
End Sub
I have report layout like:
In header area: there are 6 control Total1,
Total2.... Total6
In Detail ares: there are controls: dTotal1.......
dTotal6 and dPer1.......dPer6.
When run the report. The header ares print OK. But All
controls in Detail Areas Print something: #name?. I know
it does not find reference. As you see my code, The both
reference to the same query return fields. I do not know
why in header's areas controls' controlsource can see the
query return fields and in detail areas can not see them?
the code is here:
Query: (run fine.)
TRANSFORM Round(Sum(amr_diag03s1.Vol_SIX_06_2003)) AS
[Sum]
SELECT Modal, market, Round(Sum
(amr_diag03s1.Vol_SIX_06_2003)) AS Total
FROM amr_diag03s1
WHERE marketer<>"@unknown"
GROUP BY Modal, market
PIVOT Marketer In ('Company 1','Company 2','Company
3','Company 4');
Code: (detail area print #name? on all controls)
private sub report_open()
setLayout
end sub
Private Sub setLayout()
Dim strRecordSource As String
Me.RecordSource = above query
Me.Controls("Modal").ControlSource = "[Modal]+
[Record_type]+[Market]"
'Detail Area controls
Me.Controls("dTotal1").ControlSource = "[Company 1]"
Me.Controls("dTotal2").ControlSource = "[Company 2]"
Me.Controls("dTotal3").ControlSource = "[Company 3]"
Me.Controls("dTotal4").ControlSource = "[Company 4]"
Me.Controls("dTotal5").ControlSource = "[Total]-
[Company 1]-[Company 2]-[Company 3]-[Company 4]"
Me.Controls("dTotal6").ControlSource = "[Total]"
Me.Controls("dPer1").ControlSource = "[Company 1]"
Me.Controls("dPer2").ControlSource = "[Company 2]"
Me.Controls("dPer3").ControlSource = "[Company 3]"
Me.Controls("dPer4").ControlSource = "[Company 4]"
Me.Controls("dPer5").ControlSource = "[Total]-[Company
1]-[Company 2]-[Company 3]-[Company 4]"
Me.Controls("dPer6").ControlSource = "[Total]"
'Header Areas
Me.Controls("Total1").ControlSource = "=sum([Company
1])"
Me.Controls("Total2").ControlSource = "=sum([Company
2])"
Me.Controls("Total3").ControlSource = "=sum([Company
3])"
Me.Controls("Total4").ControlSource = "=sum([Company
4])"
Me.Controls("Total5").ControlSource = "=sum([Total]-
[Company 1]-[Company 2]-[Company 3]-[Company 4])"
Me.Controls("Total6").ControlSource = "=sum([TOTAL])"
End Sub