A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Could use so code help!



 
 
Thread Tools Display Modes
  #21  
Old December 14th, 2005, 06:40 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

Relative to the "answer" being 4 instead of 5:
The reason is very simple, 12/23 is a Friday and you have said NOT to
count Fridays as one of the days.
Now the "resolution" to that problem is probably no where near as
simple. To even attempt at a programmatic solution I would need to see
a whole series of date ranges incrementing from 2 days through the max
that you would want and have them start on the same date and tell us
the answers that you think you want the logic to return. Given that we
could probably figure out the logic of when to count friday and when
NOT to count friday (or for that matter Saturday or Sunday).

Ron

  #22  
Old December 14th, 2005, 06:46 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

It does not have to really be the MAX that you would expect but just
cover at least 2 weeks so the rule for Friday, Saturday and Sunday at
the end can be figured out.

Ron

  #23  
Old December 14th, 2005, 07:45 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

I'm not sure I am following you. As far as the logic behind it. I need
it to count the checkin date , but not count check out date. and if any
date falls on fri sat sun or holiday then it should not count for
instance check in 12/7/05 check out 12/12/05 it should return 2 for the
7th and 8th. Or check in 12/5/05 check out 12/23/05 should return 12
for the 5th-8th 12th-15th and 19th -22nd. Hope this helps

  #24  
Old December 14th, 2005, 08:27 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

OK, I misunderstood the earlier post.
Then I suggest the following change. Don't subtract the days NOT to
count but rather add up the number of days to count.

Here is the replacement logic:


Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare

dtmEnd = DateAdd("d", -1, dtmEnd) 'don't count last day
therefore don't even look at it

intTotalDays = 0 'Startwith 0 days ' We have 0 days to
start
dtmToday = dtmStart
'InitiateCompare Date

Do Until dtmToday dtmEnd
intTotalDays = intTotalDays + 1 ' Assum we will count
then take our weekend and Holiday
If Weekday(dtmToday, vbMonday) 4 Then 'It is
Saturdayor Sunday
intTotalDays = intTotalDays - 1 'Take one
dayaway for weekend
ElseIf Not IsNull(DLookup("[Holidate]", "Holidays", _
"[Holidate] = #" & dtmToday & "#")) Then 'It is
aHoliday
intTotalDays = intTotalDays - 1 'Take one
dayaway for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day
forNext Compare
Loop
'Until dtmToday dtmEnd

'All days havebeen compared

CalcWorkDays = intTotalDays 'Return the
Value
===========================================

Try that in place

  #25  
Old December 15th, 2005, 01:41 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

Ok put code in module and tried it out in immediate window, and I got
the following error.

Cmpile Error: Ambigous name detected :calcworkdays

is that saying it dosn't find that name?

  #26  
Old December 15th, 2005, 02:50 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

No, it's saying that you have two objects in your application named
calcworkdays. Use Find to locate them, and either delete or rename one of
them.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"deercreek" wrote in message
oups.com...
Ok put code in module and tried it out in immediate window, and I got
the following error.

Cmpile Error: Ambigous name detected :calcworkdays

is that saying it dosn't find that name?



  #27  
Old December 15th, 2005, 03:09 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Could use so code help!

That fixed it thanks. Still having the problem where th text field wont
update unless I change record sets and come back. Anyone have any ideas?

 




Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Barcodes Brandon Y General Discussion 6 October 18th, 2005 07:28 PM
Toolbars, Drop-Down Menus Rick New Users 1 September 21st, 2005 11:17 AM
0x80040109 error when sending from SSL SMTP krouse General Discussion 7 March 15th, 2005 01:55 AM
Excellent Navigation Method! Bill Mitchell Using Forms 3 December 16th, 2004 01:49 PM
Attn Sprinks - clarification on VB code babs Using Forms 6 December 11th, 2004 12:55 AM


All times are GMT +1. The time now is 02:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.