[AccessD] First/last day of week

John Colby jwcolby at ColbyConsulting.com
Wed Jan 18 15:52:44 CST 2006


It is very cool.  A combo where you select things like:

Last year
Last quarter
Last month
This year
This quarter
This month 

Etc etc.

Then when you select something in the combo, it sets a date range in a pair
of (typically unbound) text boxes, which you then use for queries.  The
class raises an after update event for the combo (and the same event for the
text boxes as well - you can do a custom date range) so that the form that
is using the class can then set filters, copy the dates somewhere etc.

This all started with the code by one Julie Schwalm, Backroads Data, circa
1999.  I of course changed it into a class and changed her list to a combo.

I have just added "This week" and "Today" to the list because I need to be
able to see those ranges as well.

If you want this thing:

1) Go to www.colbyconsulting.com
1a) Register if you haven't already
1b) Login
2) Click Example Code / Withevent Demos
3) Down about the middle you will see DateRangeWithEvents.zip.  Download
that.
4) Unzip it and open the file.  An example form should open.
5) play with the combo selecting different date ranges and watching the
To/From text boxes change
6) open the form to see how to use it in a form.

Notice that it uses events.  The class raises an event, and the form CAN (if
you need it to) sink that event and do something with the event.  The
example does sink the event and displays a message.  Simply delete the event
handler from the form to not have the event sunk in the form.

Enjoy.

John W. Colby
www.ColbyConsulting.com 


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim
Sent: Wednesday, January 18, 2006 2:59 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] First/last day of week

A date range selector class? Now that sounds cool.
Jim

-----Original Message-----
From: John Colby [mailto:jwcolby at colbyconsulting.com]
Sent: Wednesday, January 18, 2006 11:56 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] First/last day of week


>Busy multitasking week ..?

OMG, you can't believe! I am to the point where I am using Outlook to
schedule blocks of my time for specific client tasks.  0800-1700 filled with
1/2 hr lunch and then 2100-midnight as well.  And that for the next couple
of weeks, and possibly beyond.

Thanks for the functions.  I integrated them into my Date Range selector
class and now have a "This week" selection.

John W. Colby
www.ColbyConsulting.com 


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, January 18, 2006 11:57 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] First/last day of week

Hi John

Busy multitasking week ..?
Anyway, here are the functions we use:

Public Function DateWeekFirst( _
  ByVal datDate As Date, _
  Optional ByVal lngFirstDayOfWeek As Long = vbMonday) _
  As Date

' Returns the first date of the week of datDate.
' lngFirstDayOfWeek defines the first weekday of the week.
' 2000-09-07. Cactus Data ApS.
    
  ' No special error handling.
  On Error Resume Next
  
  ' Validate lngFirstDayOfWeek.
  Select Case lngFirstDayOfWeek
    Case _
      vbMonday, _
      vbTuesday, _
      vbWednesday, _
      vbThursday, _
      vbFriday, _
      vbSaturday, _
      vbSunday, _
      vbUseSystemDayOfWeek
    Case Else
      lngFirstDayOfWeek = vbMonday
  End Select
  
  DateWeekFirst = DateAdd("d", vbSunday - WeekDay(datDate,
lngFirstDayOfWeek), datDate)
    
End Function

Public Function DateWeekLast( _
  ByVal datDate As Date, _
  Optional ByVal lngFirstDayOfWeek As Long = vbMonday) _
  As Date

' Returns the last date of the week of datDate.
' lngFirstDayOfWeek defines the first weekday of the week.
' 2000-09-07. Cactus Data ApS.
    
  ' No special error handling.
  On Error Resume Next
  
  ' Validate lngFirstDayOfWeek.
  Select Case lngFirstDayOfWeek
    Case _
      vbMonday, _
      vbTuesday, _
      vbWednesday, _
      vbThursday, _
      vbFriday, _
      vbSaturday, _
      vbSunday, _
      vbUseSystemDayOfWeek
    Case Else
      lngFirstDayOfWeek = vbMonday
  End Select
      
  DateWeekLast = DateAdd("d", vbSaturday - WeekDay(datDate,
lngFirstDayOfWeek), datDate)
    
End Function

/gustav

>>> jwcolby at ColbyConsulting.com 18-01-2006 17:40:00 >>>
Does anyone have these functions?

John W. Colby
www.ColbyConsulting.com 


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

***********************************************************************
The information transmitted is intended solely for the individual or entity
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of or
taking action in reliance upon this information by persons or entities other
than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email, you are
responsible for screening its contents and the contents of any attachments
for the presence of viruses. No liability is accepted for any damages caused
by any virus transmitted by this email.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list