A
Andrew
Hi,
I am creating reports using the following format.
Private Sub Btn_Produce_Report_Byt_Click()
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Dim strSQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Qry_Summary_Of_Departments")
Set qdf = dbs.QueryDefs("Qry_Tbl_Range_By_Season_Data")
With rst
Do Until .EOF
The_Brand = !Company
The_Season = !Season
sSQL = "SELECT Tbl_Range_By_Season_Data.*,
Format(Now(),""dd/mm/yy"") AS As_At,
IIf(Val(Mid([Report_Period],7,2))<7,""S"",""W"") AS Period,
Left([Report_Period],4) & [Period] AS Season "
sSQL = sSQL & "FROM Tbl_Range_By_Season_Data "
sSQL = sSQL & "WHERE (((Tbl_Range_By_Season_Data.Dept) = " &
!Dept & ") And ((Tbl_Range_By_Season_Data.Company) = """ & The_Brand & """)
And ((Tbl_Range_By_Season_Data.Season) = """ & The_Season & """)) "
sSQL = sSQL & "ORDER BY Tbl_Range_By_Season_Data.Dept;"
If IsNull(!Dept) = True Then GoTo MoveNext_Part
qdf.SQL = sSQL
The_Path = "G:\00_CEN\Oth\Inventory Planning Reports\Purchase
Order Listing\" & The_Brand & "\BG" & !Bus_Group & "\" & The_Season & "\"
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand & "\BG" & !Bus_Group
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand & "\BG" & !Bus_Group & "\" & The_Season & "\"
DoCmd.OutputTo acReport, "Rpt_Range_By_Season_Report",
"SnapshotFormat(*.snp)", The_Path & "Dept " & !Dept & ".snp", True
MoveNext_Part:
.MoveNext
Loop
.Close
End With
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub
This works fine. I do need to make one change though, I need to change a
few lables and text boxes based on the season of the report. (currently the
label's name is Period_Ordered_Month_Label_1 and the caption is 'Feb', I want
it to be 'Aug'. Also text box 'Department_Ordered_Total_1' control source'
is '=Sum([FEB_07_ORD_Retail])' and I need to make it
'=Sum([AUG_07_ORD_Retail])'
What is the code to do this and where do I put it in my code?
I am creating reports using the following format.
Private Sub Btn_Produce_Report_Byt_Click()
On Error Resume Next
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim BaseSQL As String
Dim strSQL As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM Qry_Summary_Of_Departments")
Set qdf = dbs.QueryDefs("Qry_Tbl_Range_By_Season_Data")
With rst
Do Until .EOF
The_Brand = !Company
The_Season = !Season
sSQL = "SELECT Tbl_Range_By_Season_Data.*,
Format(Now(),""dd/mm/yy"") AS As_At,
IIf(Val(Mid([Report_Period],7,2))<7,""S"",""W"") AS Period,
Left([Report_Period],4) & [Period] AS Season "
sSQL = sSQL & "FROM Tbl_Range_By_Season_Data "
sSQL = sSQL & "WHERE (((Tbl_Range_By_Season_Data.Dept) = " &
!Dept & ") And ((Tbl_Range_By_Season_Data.Company) = """ & The_Brand & """)
And ((Tbl_Range_By_Season_Data.Season) = """ & The_Season & """)) "
sSQL = sSQL & "ORDER BY Tbl_Range_By_Season_Data.Dept;"
If IsNull(!Dept) = True Then GoTo MoveNext_Part
qdf.SQL = sSQL
The_Path = "G:\00_CEN\Oth\Inventory Planning Reports\Purchase
Order Listing\" & The_Brand & "\BG" & !Bus_Group & "\" & The_Season & "\"
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand & "\BG" & !Bus_Group
MkDir "G:\00_CEN\Oth\Inventory Planning Reports\Purchase Order
Listing\" & The_Brand & "\BG" & !Bus_Group & "\" & The_Season & "\"
DoCmd.OutputTo acReport, "Rpt_Range_By_Season_Report",
"SnapshotFormat(*.snp)", The_Path & "Dept " & !Dept & ".snp", True
MoveNext_Part:
.MoveNext
Loop
.Close
End With
Set qdf = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub
This works fine. I do need to make one change though, I need to change a
few lables and text boxes based on the season of the report. (currently the
label's name is Period_Ordered_Month_Label_1 and the caption is 'Feb', I want
it to be 'Aug'. Also text box 'Department_Ordered_Total_1' control source'
is '=Sum([FEB_07_ORD_Retail])' and I need to make it
'=Sum([AUG_07_ORD_Retail])'
What is the code to do this and where do I put it in my code?