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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Business Hours - can't quite get it to work 1

Status
Not open for further replies.

GotToBeABetterWay

Technical User
Mar 23, 2016
3
US
thread705-1207464

The referenced thread is exactly what I was looking for (calculating business hours between two dates). When I run my query, the calculated hours appear, then I start getting error messages and the values disappear and are replaced with #Error.

When I debug, this is what gets highlighted:

'Initalize Start and End Date Times
[highlight #FCE94F]MyDates(1).MyHrs = DateDiff("n", TimeValue(StDt), EndTim)[/highlight]
MyDates(UBound(MyDates)).MyHrs = DateDiff("n", StrtTim, TimeValue(EndDt))

I've tried replacing the DateDiff formula with a straight number (e.g. MyDates(1).MyHrs = 8). That line still gets highlighted. MyDates(1).MyHrs seems to be the source of the error.

Any ideas on what I've done wrong?

Thanks.
 
Thanks for the reply.

Hmm. Checking...

No nulls. All contain a date and time value. (e.g., 7/15/2014 2:46:23 PM)
 
I would filter the records by half and try run your query. Continue doing this to find if it's just a number of records that cause the issue. Once you find the records you should be able to find the problem and resolve it.

Duane
Hook'D on Access
MS Access MVP
 
Ah, very clever.

It seems I had an extra line of code in there to push to the morning of the next business day those start times that were after business hours. So only the time stamps after 5pm were causing the error.

Many thanks! [2thumbsup]

Now I just have to figure how out to mark this thread as solved...
 
If you want "to mark this thread as solved", award a star to Duane by clicking on "Great Post" on his reply.

And welcome to Tek-Tips [wavey3]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Yes, welcome to Tek-tips and thanks for the star.

One of my strategies for resolving any issue is to chop things into smaller pieces whether it's code or records. Sometimes I start from the smallest set and begin adding and other times it's divide in halves and repeat.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top