Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check date against holiday list

Status
Not open for further replies.

Greeneyes

Programmer
Jul 30, 2002
9
0
0
GB
Hiya,

I have a macro that needs to check a date field (today's date) is not a public holiday (these are contain in a list in a file). If's it a public holiday then to increment start date to startdate+1 and skip rest of process.

How best to approach this?

Thanks in advance.
 
If the list of holidays is short, you could put them into some variable fields and simply compare your date to each variable and, if it matches, run a macro to increment the date. This would be a series of RUN commands.

If the list is long, then you will want to use a different method. Save the identity of your current record and the date in question in variable fields. Then switch to a worksheet view of the holiday database and run a looping macro comparing the stored date to each holiday date. Note that a looping macro using Records Next will stop when it runs out of records in the current database. In the loop, if the date matches you RUN the increment macro and exit the loop. Or you run to the end and exit the loop. You would then use the variables saved to return to the form you were one originally (stored FIND) and do whatever you need to do with the variable date field.

Finally, you could write a script to take the date in question and do a SQL query against your holiday database. If no records are found you are "done" pretty quick without any loops or other problems. That script is not something I can provide here but you should be able to find examples if you search for "Resultset" on the Internet.

Sue Sloan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top