S
sara
I am new to all this - just completed a 2-day class and
having some trouble.
I have a dozen reports that my users have to create each
week (on Monday). The underlying queries all use
parameters to determine the date for data to use in each
report.
Some reports are based on more complicated queries, like
Between [Enter Sale Date] And DateAdd("d",-90,[Enter Sale
Date]), where the same date - Sale Date - is used as in
all the other reports.
I can't get the module to work with the:
Basic queries unless I take the parameter out completely
Complicated queries (like above) at all.
I have crosstabs to run, etc., and the users have to type
in the same date about 20-30 times!
Module below (if this helps)
'------------------------------------------------------
' M_Weekly_Reports
'----------------------------------------------------
Function M__Weekly_Reports()
On Error GoTo M__Weekly_Reports_Err
'Declare Variables
Dim dtReportDate As Date
Dim stDocName As String
Dim strStepErrorMsg As String
dtReportDate = InputBox("Enter Sales Date for
Reports", "Report Date Dialog Box")
stDocName = "R_Daily Over Short-Not 0"
' Daily Not TTP - enter Sales Date
strStepErrorMsg = "Tell IT there was a problem with
Daily OS not 0"
DoCmd.OpenReport stDocName, acPreview, , _
"""[Enter Sale Date] = dtReportDate"""
' 2ND REPORT Daily - more than 3 OS in 90 days - LPD
(enter Ending date - use Sales Date)
stDocName = "R_OS Details over $5 within 90 days"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Over 3 in 90 days"
DoCmd.OpenReport stDocName, acPreview, "", ""
' 3RD REPORT Daily - warning 2 OS in 90 days - Support
(Enter ending date - Use Sales Date)
stDocName = "R_OS WARNING - 2 in 90 days"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Warning 2 in 90 days"
DoCmd.OpenReport stDocName, acPreview, "", ""
' 4TH REPORT Daily - Over Short over $50 (enter Sales
Date - pulls for the prior 7 days)
stDocName = "R_OverShort Over 50"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Over 50"
DoCmd.OpenReport stDocName, acPreview, "", ""
M__Weekly_Reports_Exit:
Exit Function
M__Weekly_Reports_Err:
MsgBox strStepErrorMsg
MsgBox Err.Description
Resume M__Weekly_Reports_Exit
End Function
Thanks - I need to get this automated before I go on
vacation (Though I'm on my way to crazy first, I think!)
Sara
having some trouble.
I have a dozen reports that my users have to create each
week (on Monday). The underlying queries all use
parameters to determine the date for data to use in each
report.
Some reports are based on more complicated queries, like
Between [Enter Sale Date] And DateAdd("d",-90,[Enter Sale
Date]), where the same date - Sale Date - is used as in
all the other reports.
I can't get the module to work with the:
Basic queries unless I take the parameter out completely
Complicated queries (like above) at all.
I have crosstabs to run, etc., and the users have to type
in the same date about 20-30 times!
Module below (if this helps)
'------------------------------------------------------
' M_Weekly_Reports
'----------------------------------------------------
Function M__Weekly_Reports()
On Error GoTo M__Weekly_Reports_Err
'Declare Variables
Dim dtReportDate As Date
Dim stDocName As String
Dim strStepErrorMsg As String
dtReportDate = InputBox("Enter Sales Date for
Reports", "Report Date Dialog Box")
stDocName = "R_Daily Over Short-Not 0"
' Daily Not TTP - enter Sales Date
strStepErrorMsg = "Tell IT there was a problem with
Daily OS not 0"
DoCmd.OpenReport stDocName, acPreview, , _
"""[Enter Sale Date] = dtReportDate"""
' 2ND REPORT Daily - more than 3 OS in 90 days - LPD
(enter Ending date - use Sales Date)
stDocName = "R_OS Details over $5 within 90 days"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Over 3 in 90 days"
DoCmd.OpenReport stDocName, acPreview, "", ""
' 3RD REPORT Daily - warning 2 OS in 90 days - Support
(Enter ending date - Use Sales Date)
stDocName = "R_OS WARNING - 2 in 90 days"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Warning 2 in 90 days"
DoCmd.OpenReport stDocName, acPreview, "", ""
' 4TH REPORT Daily - Over Short over $50 (enter Sales
Date - pulls for the prior 7 days)
stDocName = "R_OverShort Over 50"
strStepErrorMsg = "Tell IT there was a problem with
Daily OS Over 50"
DoCmd.OpenReport stDocName, acPreview, "", ""
M__Weekly_Reports_Exit:
Exit Function
M__Weekly_Reports_Err:
MsgBox strStepErrorMsg
MsgBox Err.Description
Resume M__Weekly_Reports_Exit
End Function
Thanks - I need to get this automated before I go on
vacation (Though I'm on my way to crazy first, I think!)
Sara