SmileyFace
Programmer
I am trying to retrieve data for the previous month...since it is Jan right now, the formula Month(CurrentDate)-1 generates a '0' which gives an error: "A month number must be between 1 and 12". To bypass this the following code was written, but doesn't seem to work...please note what is highlighted...
if {?ReportPeriod} = "CurrentMonth" then
if {?ReportSite} = "X" then
"Created in " + ToText(CurrentDate, "MMMM yyyy")
else
"Created in " + ToText(CurrentDate, "MMMM yyyy") + " for " + {?ReportSite}
else
if {?ReportPeriod} = "PreviousMonth" then
if Month(CurrentDate) = 1 then (...here is where it should go in the loop)
if {?ReportSite} = "X" then
"Create in December " + ToText(Year(CurrentDate)-1)
else
"Created in December " + ToText(Year(CurrentDate)-1) + " for " + {?ReportSite}
else (...but it still seems to be coming into the 'else' section and giving that error)
if {?ReportSite} = "X" then
"Created in " + ToText(DateTime(Year(CurrentDate), Month(CurrentDate)-1, Day(CurrentDate)), "MMMM yyyy")
else
"Created in " + ToText(DateTime(Year(CurrentDate), Month(CurrentDate)-1, Day(CurrentDate)), "MMMM yyyy") + " for " + {?ReportSite}
else
if {?ReportSite} = "X" then
{?ReportPeriod}
else
{?ReportPeriod} + " for " + {?ReportSite}
I would really appreciate any help offered with this. Thanks in advance!!
if {?ReportPeriod} = "CurrentMonth" then
if {?ReportSite} = "X" then
"Created in " + ToText(CurrentDate, "MMMM yyyy")
else
"Created in " + ToText(CurrentDate, "MMMM yyyy") + " for " + {?ReportSite}
else
if {?ReportPeriod} = "PreviousMonth" then
if Month(CurrentDate) = 1 then (...here is where it should go in the loop)
if {?ReportSite} = "X" then
"Create in December " + ToText(Year(CurrentDate)-1)
else
"Created in December " + ToText(Year(CurrentDate)-1) + " for " + {?ReportSite}
else (...but it still seems to be coming into the 'else' section and giving that error)
if {?ReportSite} = "X" then
"Created in " + ToText(DateTime(Year(CurrentDate), Month(CurrentDate)-1, Day(CurrentDate)), "MMMM yyyy")
else
"Created in " + ToText(DateTime(Year(CurrentDate), Month(CurrentDate)-1, Day(CurrentDate)), "MMMM yyyy") + " for " + {?ReportSite}
else
if {?ReportSite} = "X" then
{?ReportPeriod}
else
{?ReportPeriod} + " for " + {?ReportSite}
I would really appreciate any help offered with this. Thanks in advance!!