Something wrong with using the Weekday function, rather than creating your
own? <g>
Weekday(Date, vbSunday) - 1 will return exactly what offset contains when
you're done.
I really question the declaration of offset as a variant, and then sometimes
storing a string in it, and then a number. If you give that code to someone
using a different language, it's going to fail. For instance, a French user
will be getting Dim, Lun, Mar, Mer, Jeu, Ven, Sam rather than Sun, Mon, Tue,
Wed, Thu, Fri, Sat. Therefore, offset is still going to be a string after
the Switch function is applied.
--
Doug Steele, Microsoft Access MVP
(No private e-mails, please)
DevalilaJohn said:
In your event procedure to run ther report add:
Dim offset
Dim stDocName As String
offset = Format(Date, "ddd")
offset = Switch(offset = "sun", 0, _
offset = "mon", 1, _
offset = "tue", 2, _
offset = "wed", 3, _
offset = "thu", 4, _
offset = "fri", 5, _
offset = "sat", 6)
stDocName = [YourReportName
DoCmd.OpenReport stDocName, acPreview, , [YourDateField] > DateAdd("d",
-offset, Date)
Assuming that you keep your data down to a manageable size this will
automate your process.
Brent said:
I have created reports linked to queries. I will use these same reports on a
daily basis. On Tuesday I need to report Mondays numbers. On Wednesday I
need Monday and Tuesdays numbers on there. And so on until on Monday I need
the whole prior week. How do I do this?