Module for date in a report

Jaspal

Jas
Local time
Today, 03:23
Joined
Dec 31, 2004
Messages
38
Basically i have a report that is raised every thursday, in the title i want to specify the date for the friday. For example this week the report will be raised on the 3rd feb, when it is the title wnats to read "Report for ...... 04/02/2005. I know that this is simple enough however, sometimes the report maybe raised on any particular day of the week, but the title needs to show the date for the friday of the week concerned.

I have the code written in a module, as advised from a previous thread. The Code in the module is as follows;

Function WeekEndingFriday(AnyDate As Date) As Date

If Weekday(AnyDate) = vbMonday Then
WeekEndingFriday = AnyDate + 4
ElseIf Weekday(AnyDate) = vbTuesday Then
WeekEndingFriday = AnyDate + 3
ElseIf WeekEndingFriday = vbWednesday Then
WeekEndingFriday = AnyDate + 2
ElseIf Weekday(AnyDate) = vbThursday Then
WeekEndingFriday = AnyDate + 1
ElseIf WeekEndingFriday = vbFriday Then
WeekEndingFriday = AnyDate
Else

End If

End Function

I reference this module in my report, however when i open the report it asks me to enter the parameter value for <AnyDate>. But even when i do this it returns zero's. i want the report to open and just have the date for the friday of that week displayed without having to input a value

Help Please :confused: !
 
Where you reference the module you must supply AnyDate:
In this case (Date) supplies todays date as AnyDate

Call WeekEndingFriday(Date)
 
I wouldn't use multiple iif's a select case statement would be better, however in this case a single line will suffice

Public Function LastFriWeek(YourDate As Date) As Date
LastFriWeek = YourDate - WeekDay(YourDate) + 6
End Function

Pat Hartman has posted a useful date functions db in the samples forum which you might like to refer too
 

Users who are viewing this thread

Back
Top Bottom