ACC: How to Determine If a Date Falls on a Weekend or HolidayLast reviewed: August 28, 1997Article ID: Q149127 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article demonstrates how to use Visual Basic for Applications to determine if a date falls on a weekend or holiday. This example is useful for setting due dates in applications that have billing or invoicing features. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.
MORE INFORMATIONThe following sample procedure uses the WeekDay() function to determine if a specific date falls on a Saturday or Sunday. Then, it uses a DLookup() function to determine if it falls on a date stored in a user-created Holidays table.
Creating a Holidays TableThe following sample procedure requires a table with a particular structure for storing Holiday dates. You can follow these steps for creating the table and sample records:
Creating the Custom ProcedureTo create a function that determines if a date falls on a weekend or holiday, follow these steps:
Usage ExampleYou can use the custom OfficeClosed() function to calculate due dates. For example, if your office or business is closed for a 3-day weekend, you may want to extend your customers' grace period for their outstanding bills. Here's sample code for adding one more day to a grace period:
DueDate=OrderDate+30 Do While OfficeClosed(DueDate) DueDate=DateDue+1 Loop REFERENCESFor more information about the Weekday() function, search the Help Index for "weekday," or ask the Microsoft Access 97 Office Assistant. For more information about the DLookup() function, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q108098 TITLE : ACC1x: DLookup() Usage, Examples, and Troubleshooting Tips Keywords : kbusage PgmHowTo Version : 7.0 97 Platform : WINDOWS Hardware : x86 Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |