Article ID: 290152 - Last Review: October 11, 2006 - Revision: 3.2 How to determine if a date falls on a weekend or a on holiday in Access 2002This article was previously published under Q290152 On This PageSUMMARY
This article shows you how to create a Visual Basic for Applications
function 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. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following example uses the WeekDay() function to determine if a specific date falls on a Saturday or a Sunday. Then, it uses the DLookup() function to determine if the date falls on a date that is stored in a user-created Holidays table. Creating the Holidays TableThe following example requires a table with a particular structure for storing Holiday dates. To create the table and sample records, follow these steps:
Creating the Custom FunctionTo 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 three-day weekend, you may want to extend your customers' grace period for their outstanding bills. The following is sample code for adding one more day to a grace period:REFERENCESFor more information about the Weekday() function, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type weekday function in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For additional information about the DLookup() function, click the following article number to view the article in the Microsoft Knowledge Base: 285866
(http://support.microsoft.com/kb/285866/
)
Description of DLookup() usage, examples, and troubleshooting
| Article Translations
|
Back to the top
