Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-2008, 02:53 PM
=?Utf-8?B?U3RvY2t3ZWxsNDM=?=
 
Posts: n/a
Date plus 10 Working days

Hello,

Is there a way to place a text box on a form that will retrieve a Date from
the following:

OriginalDate +10 Working days (week days no weekends)
I want the +10 Working days date in the textbox. We'll call it "CutoffDate"

Thanks!!
Reply With Quote
  #2 (permalink)  
Old 07-24-2008, 03:02 PM
Jeff Boyce
 
Posts: n/a
Re: Date plus 10 Working days

While there are routines (try checking mvps.org/access) to "calculate"
"working days", won't that really depend on whether you have a table of
holidays. I assume you wish to eliminate not only weekends but holidays,
too.

After all, if the only thing you wanted to do was add 10 working days, you
could just add 2 weeks (since weekends add two more days each).

Regards

Jeff Boyce
Microsoft Office/Access MVP


"Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> Hello,
>
> Is there a way to place a text box on a form that will retrieve a Date
> from
> the following:
>
> OriginalDate +10 Working days (week days no weekends)
> I want the +10 Working days date in the textbox. We'll call it
> "CutoffDate"
>
> Thanks!!



Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 03:04 PM
Jeff Boyce
 
Posts: n/a
Re: Date plus 10 Working days

By the way, take a look at the DateAdd() function. You can use it to add
units-of-time (e.g., minutes, hours, days, weeks, etc) to a date. You can
add an event procedure to your [OriginalDate] field that calculates the new
date value and places that in your textbox.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> Hello,
>
> Is there a way to place a text box on a form that will retrieve a Date
> from
> the following:
>
> OriginalDate +10 Working days (week days no weekends)
> I want the +10 Working days date in the textbox. We'll call it
> "CutoffDate"
>
> Thanks!!



Reply With Quote
  #4 (permalink)  
Old 07-24-2008, 03:07 PM
Arvin Meyer [MVP]
 
Posts: n/a
Re: Date plus 10 Working days

http://www.datastrat.com/Code/GetBusinessDay.txt

is exactly what you want.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> Hello,
>
> Is there a way to place a text box on a form that will retrieve a Date
> from
> the following:
>
> OriginalDate +10 Working days (week days no weekends)
> I want the +10 Working days date in the textbox. We'll call it
> "CutoffDate"
>
> Thanks!!



Reply With Quote
  #5 (permalink)  
Old 07-24-2008, 04:03 PM
Dirk Goldgar
 
Posts: n/a
Re: Date plus 10 Working days

"Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> Hello,
>
> Is there a way to place a text box on a form that will retrieve a Date
> from
> the following:
>
> OriginalDate +10 Working days (week days no weekends)
> I want the +10 Working days date in the textbox. We'll call it
> "CutoffDate"



(My first reply to this post doesn't seem to have made it to the newsgroup.)

See this link:

http://www.mvps.org/access/datetime/date0012.htm
Date/Time: Doing WorkDay Math in VBA

With the functions posted there saved in a standard module, you could set
the controlsource of CutoffDate to

=dhAddWorkDaysA(10, [OriginalDate])

Note that, as a calculated value, the value of CutoffDate would not normally
be saved in your form's underlying table.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Reply With Quote
  #6 (permalink)  
Old 07-24-2008, 04:05 PM
=?Utf-8?B?U3RvY2t3ZWxsNDM=?=
 
Posts: n/a
Re: Date plus 10 Working days

Hi Guys, thank you for all your responses!!!

Jeff, you correct about the holidays. My initial thought was to use
turnaroun time in number of workdays instead of the date and place a checkbox
on the form that would subtract one from the turntime if a holiday fell
within that range. I decided to show the date instead to give the manager a
visual.

I did try the DateAdd but it only adds 10 days not 10 working days.

Dirk, I tried your recommendation and it worked fine but it was adding 10
dates to the Original date so if I have 7/15/2008 in original date,
CutoffDate displayed 7/25/2008 unless I did something wrong which I wouldn't
be surprised.

Also, you correct, it will not be placed in the table. it's more for a report.

Arvin, I tried yours and I get #Nam! in the CutoffDate box. I have this in
the control Source =GetBusinessDay(10,[OriginalDate]) Should I have it in an
event procedure instead?

Guys,

I am sure I am doing something wrong. I pasted the enitre code from each in
separate modules (Arvin Module 3, Dirk Module 5) and I can't seem to get it
right. Sorry about this. Any suggestions?

Thanks!



"Arvin Meyer [MVP]" wrote:

> http://www.datastrat.com/Code/GetBusinessDay.txt
>
> is exactly what you want.
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
>
> "Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
> news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> > Hello,
> >
> > Is there a way to place a text box on a form that will retrieve a Date
> > from
> > the following:
> >
> > OriginalDate +10 Working days (week days no weekends)
> > I want the +10 Working days date in the textbox. We'll call it
> > "CutoffDate"
> >
> > Thanks!!

>
>
>

Reply With Quote
  #7 (permalink)  
Old 07-24-2008, 04:16 PM
=?Utf-8?B?U3RvY2t3ZWxsNDM=?=
 
Posts: n/a
Re: Date plus 10 Working days

Hi Dirk,

I added all the code from the site and placed it in a module. I place the
line you gave me in my control source and when I open the form if it's a new
record, I get Error# in the CutoffDate field and if there is an OriginalDate
then it gives me a date in the CutoffDate field but it is 10 days from the
Original Date not 10 working days. I'm sure I must have done something wrong.

"Dirk Goldgar" wrote:

> "Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
> news:6EE58531-7018-4A5E-B67C-F4E1AD05BECB@microsoft.com...
> > Hello,
> >
> > Is there a way to place a text box on a form that will retrieve a Date
> > from
> > the following:
> >
> > OriginalDate +10 Working days (week days no weekends)
> > I want the +10 Working days date in the textbox. We'll call it
> > "CutoffDate"

>
>
> (My first reply to this post doesn't seem to have made it to the newsgroup.)
>
> See this link:
>
> http://www.mvps.org/access/datetime/date0012.htm
> Date/Time: Doing WorkDay Math in VBA
>
> With the functions posted there saved in a standard module, you could set
> the controlsource of CutoffDate to
>
> =dhAddWorkDaysA(10, [OriginalDate])
>
> Note that, as a calculated value, the value of CutoffDate would not normally
> be saved in your form's underlying table.
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>

Reply With Quote
  #8 (permalink)  
Old 07-24-2008, 04:18 PM
Krzysztof Pozorek [MVP]
 
Posts: n/a
Re: Date plus 10 Working days

(...)
> Is there a way to place a text box on a form that will retrieve a Date
> from
> the following:
>
> OriginalDate +10 Working days (week days no weekends)
> I want the +10 Working days date in the textbox. We'll call it
> "CutoffDate"


Write the following function:

Public Function GetD(OrigD As Date, n As Long)
Dim i As Long
Do While i < n
OrigD = OrigD + 1
If Weekday(OrigD, 2) < 6 Then i = i + 1
Loop
GetD = OrigD
End Function

How to use:

YourDate = GetD(Date, 6)

K.P.


Reply With Quote
  #9 (permalink)  
Old 07-24-2008, 04:29 PM
Arvin Meyer [MVP]
 
Posts: n/a
Re: Date plus 10 Working days


"Stockwell43" <Stockwell43@discussions.microsoft.com> wrote in message
news:A9E247A3-C089-4305-B0EE-91605C11D4ED@microsoft.com...

> Arvin, I tried yours and I get #Nam! in the CutoffDate box. I have this in
> the control Source =GetBusinessDay(10,[OriginalDate]) Should I have it in
> an
> event procedure instead?


I usually use an event procedure, but you have it backwards anyway, and this
might fix it:


= GetBusinessDay([Forms]![Your Correct Form Name]![OriginalDate],10)
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com



Reply With Quote
  #10 (permalink)  
Old 07-24-2008, 04:33 PM
=?Utf-8?B?U3RvY2t3ZWxsNDM=?=
 
Posts: n/a
Re: Date plus 10 Working days

Hi,

Thank you for your reply.

I place your code in a module name Module12

The other piece under How to Use I place in the Control Source of the
textbox I want to display the CutoffDate. I changed the YourDate to Original
date as this is the date I want to be the driver. and I a get #Name? Did I do
something wrong?

"Krzysztof Pozorek [MVP]" wrote:

> (...)
> > Is there a way to place a text box on a form that will retrieve a Date
> > from
> > the following:
> >
> > OriginalDate +10 Working days (week days no weekends)
> > I want the +10 Working days date in the textbox. We'll call it
> > "CutoffDate"

>
> Write the following function:
>
> Public Function GetD(OrigD As Date, n As Long)
> Dim i As Long
> Do While i < n
> OrigD = OrigD + 1
> If Weekday(OrigD, 2) < 6 Then i = i + 1
> Loop
> GetD = OrigD
> End Function
>
> How to use:
>
> YourDate = GetD(Date, 6)
>
> K.P.
>
>
>

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:44 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108