I believe I said you should have been using
DateAddW([START DATE], [days 10] + [days 20])
The equivalent with the code from
http://www.mvps.org/access/datetime/date0012.htm should be
dhAddWorkDaysA([days 10] + [days 20], [StartDate])
This, of course, assumes that both days 10 and days 20 have valid numbers
in
them. To be safe, you should probably use
dhAddWorkDaysA(Nz([days 10],0) + Nz([days 20], 0), [StartDate])
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hello Douglas - me again - sorry had another look through and have now
obviously used all of the coding. I selected it all and copied it into
a
new
module.
So now where do I go from here.
What do I use instead of DateAddW and also to get the correct START
DATE.
I think I am in above my head but I will give it a go.
Thank you.
:
I'm sorry: I've given you references to two routines that I know work.
I
don't have the time to try and figure out why the KB's code doesn't.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Thank you once again - I have been looking at it too much.
So I understand that it automatically adds the value. I think the
problem
is that all my numbers are positive.
I meant to write Total Days not date.
What I am doing is adding together all the manufacturing days
together
from
a form. I then want to subtract the total manufacturing days (work
days)
from the SHIP DATE to give the START DATE.
So my Total Days is a positive number?
Thank you for you help and I hope you can help me solve it.
Kristal
:
It automatically adds the value. If the value's negative, it gives
you
that
many business days prior to the date. If the value's positive, it
gives
you
that many business days after the date. Putting a plus sign in
front
isn't
going to do anything for you: if the number is negative, you're
still
going
to be subtracting.
Assuming Total Date is a date, it's hardly surprising that Ship
Date -
Total
Date gave an odd date. (If you meant to type Total Days, not Total
Date,
then I'm not sure: I haven't looked that closely at the code to see
whether
there are bugs in it)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
message
It was going so well and now I have changed that I have a whole
load
of
errors and it still doesn't work. I am giving up for now and
look
at
other
ways.
How does it know to + or - if you do not have any symbols?
Also with the odd date that it was giving - it worked if I did
SHIP
DATE +
TOTAL DAYS but gave out an odd date if it was SHIP DATE - TOTAL
DATE
Any thoughts?
When I get a chance I will look at your web site and use your
coding
but I
just don't fancy starting again as it was all going so well.
Thank you.
:
It's not required (nor is a + sign required before [days 10])
As to your other question (about why it was a number one time,
and
an
odd
date another time), at least part of the problem is because
that's
lousy
code!
Function DateAddW (ByVal TheDate, ByVal Interval)
should be
Function DateAddW (ByVal TheDate As Date, ByVal Interval As
Long)
As
Date
For better alternatives, see
http://www.mvps.org/access/datetime/date0012.htm at "The Access
Web"
or
my
"Access Answers" column in the September, 2004 issue of Pinnacle
Publication's "Smart Access". You can download the column (and
sample
database) for free at
http://www.accessmvp.com/djsteele/SmartAccess.html
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
message
MOVE ON BY: DateAddW([START DATE], [days 10] + [days 20])
Hi Douglas me again - just looking at your above statement are
you
missing
the + symbol before [START DATE]??
:
Looking at that KB article, you should have:
MOVE ON BY 10: DateAddW([START DATE], [days 10])
To add the number of days from multiple fields, try:
MOVE ON BY: DateAddW([START DATE], [days 10] + [days 20])
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
in
message
Thank you for that - I had pasted it to a module but called
it
DateAddW
so
that is where I was going wrong.
The next problem I am having is that it works for the below
MOVE ON BY 10: DateAddW(+[days 10],[START DATE])
but how do I change it to add more than two field together
for
example
days 10 + days 20 + START DATE?
:
That KB article includes the code for the DateAddW
function:
it's
in
the
shaded area under Resolution.
Copy all of that and paste it into a module in your
application.
Do
not
name
the module DateAddW: modules cannot be named the same as
routines
(subs
or
functions)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
"Kristaltips" <
[email protected]>
wrote
in
message
I am running a query using the DateAdd function. It
works
fine
MOVE ON BY: DateAdd("y",+[days 10],[START DATE])
but I would like it to exclude weekend dates.
I looked on the website below and they mentioned using
DateAddW
but
I
get
an error message of Undefined Funtion DateAddW
http://support.microsoft.com/kb/115489/en-us