how to store half day (1 Viewer)

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
I have a table that stores beginning vacation and ending holiday date. I use

=IIf(IsNull([Day]) Or IsNull([DayTo]),1,funWorkDaysDifference([Day],[DayTo]))

to get the work days between the dates. I used to manually enter how many days was between those dates but after I found that formula I have it automatically calculate and I dont need to store it any more since I can calculate it.

My question is how would I record if the employee takes a half a vacation day? Does this need to be stored? Or should I add a check box or something to indicate a half day?
 

Mile-O

Back once again...
Local time
Today, 23:48
Joined
Dec 10, 2002
Messages
11,316
On your holiday table I'd add a checkbox which would be checked for half days.

When totalling the number of days you could count the full days and then count the half days, remembering to divide the half days by 2.

Then add the (half days divided by 2) to the total of full days.
 

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
thanks Mile!

You da man!
 

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
how would I change that command to check if the check box is checked and insert ".5" into the "totalDays" textbox?
 

Attachments

  • iif.jpg
    iif.jpg
    49.2 KB · Views: 84

Mark Wild

Registered User.
Local time
Today, 23:48
Joined
Apr 9, 2003
Messages
126
Try something along the lines of

dim intDays as integer

intDays=me.TotalDAys

if me.halfDay=-1 then
intDays=intdays+0.5
end if

I'd probably place it on the on_change function of HalfDay. If you do go down this route, have another statement to reverse it - ie the user ticks and then unticks the box
 

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
thanks for the try but it give me error 2108. I need to save first. Any ideas?
 

Mark Wild

Registered User.
Local time
Today, 23:48
Joined
Apr 9, 2003
Messages
126
See if this works
 

Attachments

  • chewy.zip
    36.8 KB · Views: 96

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
What the problem seems to be is in the toaldays textbox I have this statement to count the number of days between two dates.

=IIf(IsNull([Day]) Or IsNull([DayTo]),1,funWorkDaysDifference([Day],[DayTo]))

If I take this out of the control source it works fine but if not I get the error
 
Last edited:

Mark Wild

Registered User.
Local time
Today, 23:48
Joined
Apr 9, 2003
Messages
126
Chewy,

I put the following code behind the DateTo box and got it working

Private Sub TbDateto_afterupdate()

If IsNull(Me.TbDate) Then
MsgBox "please enter a Date", vbCritical
Exit Sub
End If

If IsNull(Me.TbDateto) Then
MsgBox "please enter a Date to", vbCritical
Exit Sub
End If

Me.TbtotalDays = DateDiff("d", Me.TbDate, Me.TbDateto)

End Sub
 

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
maybe you could check out my DB
 

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
here it is sorry
 

Attachments

  • time off.zip
    97.7 KB · Views: 98

chewy

SuperNintendo Chalmers
Local time
Today, 23:48
Joined
Mar 8, 2002
Messages
581
nevermind. I just added this to the "Total Days" textbox

=(IIf(IsNull([Day]) Or IsNull([DayTo]),1,funWorkDaysDifference([Day],[DayTo])))+(IIf([check12]=-1,0.5,0))

Thanks for your help!
 

Mark Wild

Registered User.
Local time
Today, 23:48
Joined
Apr 9, 2003
Messages
126
No probs,

If you get the chance try popping the code you've got into a sub as you will be able to control the other fields more (ie if they haven't been completed) and also write comments to remind yourself and others what is happening.

Also, you can tick the check box before the total days is filled in. Your code is unlikley to add the half day if the check is there already...

Cheers,

M
 

Users who are viewing this thread

Top Bottom