working days formula
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Working days formula

Working days formula

resolvedResolved · High Priority · Version 2003

replyReply Wed 19 Aug 2009, 15:40Delegate James said...

James has attended:
Access VBA course

Working days formula

calculating working days diff rather than daysdiff.
steve asked to post reminder

For upcoming training course dates see: Pricing & availability

replyReply Wed 26 Aug 2009, 11:59Trainer Jacob said...

RE: working days formula

Hi James

Thanks for the post, Stephen is available tomorrow and will review your post.

regards

Jacob

replyReply Fri 11 Sep 2009, 17:01Delegate James said...

RE: working days formula

Still no reply to my question

Unless I am missing it?

replyReply Mon 26 Oct 2009, 15:25 Edited on Mon 26 Oct 2009, 15:26Trainer Stephen said...

RE: working days formula

Hi James

Apologies, I was sure I had answered this but I can find no reference to it, so I can only imagine that there was some glitch when I tried to post.

The following function will count the working days between two dates, by excluding Saturdays and Sundays.

Function WorkDays(dteStart As Date, dteFinish As Date) As Integer

Dim dteDateCount As Date
Dim intCount As Integer

For dteDateCount = dteStart To dteFinish

If Weekday(dteDateCount) <> 7 Then 'excludes saturdays

If Weekday(dteDateCount) <> 1 Then 'excludes sundays

intCount = intCount + 1

End If

End If

Next dteDateCount

WorkDays = intCount

End Function


It uses the vb function weekdays to exclude dates on a saturday (day7) or a sunday(day1).

The following procedure calls this function and places two dates for the start and finish arguments

Sub Caller()

MsgBox WorkDays(#10/19/2009#, #10/28/2009#)


End sub


Hope this helps

Regards

Stephen

Mon 2 Nov 2009: Automatically marked as resolved.

 

Please browse our web site to find out more about
access database microsoft training and other Microsoft training courses.

Access tip:

Closing form after a certain time period

To make a form close automatically after a certain time period, you need to assign the close function to a macro.

Save the macro and ope up the form in design view. open the Properties sheet.

In the TimerInterval property enter the length of time you want the form open for. This should be in milliseconds, so for instance if you want the form open for 5 seconds enter 5000, for an minute enter 60000.

You now need to attach your macro (to execute the Close action) to the OnTimer event property of the form.



View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard