Problem with Add Workday function

F

FEleazer

I've copied the function recommended to add workdays to a date from the MVPs
website (http://www.mvps.org/access/datetime/date0012.htm) but when I try and
use it in a query I get an error message:
Data type mismatch in criteria expression

My calculation looks like this: NewDateInclHolidays: dhAddWorkDaysA(10,
[HoldDate],array(#1/2/2006#))

I tried it without the Holiday Array and it works fine. What am I doing
wrong? I have a Holiday table that I use for another function, can I use
this instead of the array?
 
D

Douglas J Steele

I just did a quick sample test, pasting your exact code into a query
(changing [HoldDate] to the name of the field in my table), and it worked
fine for me.

Did you copy-and-paste the code from the website, or did you retype it? If
you typed it, are you sure the declaration is correct?
 
F

FEleazer via AccessMonster.com

Thanks for the quick reply!
I copy and pasted it at the end of a module that had another function in it
and named the module "DateMath".
If I don't put the array in it it runs fine, that's why I thought maybe there
was a way to do it without the array and use a Holiday table instead (also
would make updating easier).

I just did a quick sample test, pasting your exact code into a query
(changing [HoldDate] to the name of the field in my table), and it worked
fine for me.

Did you copy-and-paste the code from the website, or did you retype it? If
you typed it, are you sure the declaration is correct?
I've copied the function recommended to add workdays to a date from the MVPs
website (http://www.mvps.org/access/datetime/date0012.htm) but when I try and
[quoted text clipped - 7 lines]
wrong? I have a Holiday table that I use for another function, can I use
this instead of the array?
 
D

Douglas J Steele

If you wanted to use a Holiday table rather than passing the array, you'd
have to do a fairly extensive rewrite of Ken's code, since the array gets
passed from routine to routine a fair bit.

I think I showed how to use a Holiday table in my September, 2004 "Access
Answers" column in Pinnacle Publication's "Smart Access" You can download
the column (and sample database) for free at
http://www.accessmvp.com/DJSteele/SmartAccess.html

You might also want to check my June, 2005 column for one way to populate
your Holiday table.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


FEleazer via AccessMonster.com said:
Thanks for the quick reply!
I copy and pasted it at the end of a module that had another function in it
and named the module "DateMath".
If I don't put the array in it it runs fine, that's why I thought maybe there
was a way to do it without the array and use a Holiday table instead (also
would make updating easier).

I just did a quick sample test, pasting your exact code into a query
(changing [HoldDate] to the name of the field in my table), and it worked
fine for me.

Did you copy-and-paste the code from the website, or did you retype it? If
you typed it, are you sure the declaration is correct?
I've copied the function recommended to add workdays to a date from the MVPs
website (http://www.mvps.org/access/datetime/date0012.htm) but when I
try and
[quoted text clipped - 7 lines]
wrong? I have a Holiday table that I use for another function, can I use
this instead of the array?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top