News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Test Routine for the SkipHolidays Function

Started by sukishan, Sep 04, 2009, 04:49 PM

Previous topic - Next topic

sukishan

Test Routine for the SkipHolidays Function

Sub TestSkipHolidays()
    Dim rst As DAO.Recordset
    Dim db As DAO.Database
    Set db = DAO.DBEngine.OpenDatabase("Holidays.MDB")
    Set rst = db.OpenRecordset("tblHolidays", _
     DAO.dbOpenDynaset)
    Debug.Print dhFirstWorkdayInMonth(#1/1/97#, rst, "Date")
    Debug.Print dhLastWorkdayInMonth(#12/31/97#, rst, "Date")
    Debug.Print dhNextWorkday(#5/23/97#, rst, "Date")
    Debug.Print dhNextWorkday(#5/27/97#, rst, "Date")
    Debug.Print dhPreviousWorkday(#5/27/97#, rst, "Date")
    Debug.Print dhPreviousWorkday(#5/23/97#, rst, "Date")
End SubIf you don't have Jet and DAO or you just don't care about holidays, you could also call these routines like this:

Debug.Print dhFirstWorkdayInMonth(#1/1/97#)
' or
Debug.Print dhLastWorkdayInMonth(#12/31/97#)In this case, the procedure calls would just skip weekend days, if necessary, to return the first and last workday, respectively.

The sample CD with this book includes HOLIDAYS.MDB (which contains tblHolidays), which you can use as a start for preparing your list of holidays. If you have any product that can work with Access databases, you're ready to start filling in your own list of holidays for use with these routines. If not, we've included HOLIDAYS.TXT, a text file you can import into your own database program for use with these samples. Of course, if you're not using Jet as your database engine, you'll need to modify the code in the samples accordingly.
A good beginning makes a good ending