how to store half day

chewy

SuperNintendo Chalmers
Local time
Today, 06:33
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?
 
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.
 
thanks Mile!

You da man!
 
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: 124
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
 
thanks for the try but it give me error 2108. I need to save first. Any ideas?
 
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:
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
 
maybe you could check out my DB
 
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!
 
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

Back
Top Bottom