View Single Post
  #6  
Old April 24th, 2010, 12:39 AM posted to microsoft.public.access.tablesdbdesign
Barry A&P[_2_]
external usenet poster
 
Posts: 119
Default Automatic Annual Leave

Barnstar
I am also new to access an have greatly enjoyed trying to figure out how to
do the things i want to do..
Since i havent seen any specific suggestions on your setup let me throw out
my two cents.. on at least a newbies suggestion how to start.

i would think you need an employees table
T_Employees
EmployeeID (PK)
FName
LName
and whatever else you want in the table

A Leave table
T_Leave
LeaveID (PK)
EmployeeID (FK)
LeaveStartTime
LeaveStopTime

then you could have a form F_LeaveRequest with the employees info and two
unbound boxes for LeavestartTime and LeaveStopTime
and a Submit Leave Button

in the buttons on-click event start with something like this

Private Sub CMD_Submit_Click()
Dim MatchCount As Integer

If IsNull([Forms]![F_LeaveRequest]![LeaveStartTime]) Or
IsNull([Forms]![F_LeaveRequest]![LeavestopTime]) Then
MsgBox "Start or End Time cant be Empty", vbOKOnly
Else

If DCount("leaveID", "T_Leave", "T_Leave.LeaveStartTime Between
[Forms]![F_LeaveRequest]![LeaveStartTime] And
[Forms]![F_LeaveRequest]![LeaveStopTime] OR T_Leave.LeaveStopTime Between
[Forms]![F_LeaveRequest]![LeaveStartTime] And
[Forms]![F_LeaveRequest]![LeaveStopTime]") 0 Then
MsgBox "somebody allready has requested leave during that period", vbOKOnly
Else
If MsgBox("The leave you requested is available", vbOKCancel) =
vbCancel Then
Exit Sub
Else
'SetWarnings = False 'Un-Comment this to stop the update warnings
Please Be carefull when turning warnings off
DoCmd.RunSQL "INSERT INTO T_Leave ( LeaveStartTime, LeaveStopTime,
EmployeeID ) " & _
"SELECT [Forms]![F_LeaveRequest]![LeaveStartTime] AS LeaveStartTime,
" & _
"[Forms]![F_LeaveRequest]![LeaveStopTime] AS LeavestopTime, " & _
"[Forms]![F_LeaveRequest]![EmployeeID] AS EmployeeID"
SetWarnings = True
End If
End If
End If

End Sub

Of course there is a Ton more stuff you need to accomplish but sometimes a
little something to get the ball rolling helps alot

Duane Hookum has a CalendarReports.mdb sample that might have a good example
of a timeline type report that may help spot available Leave periods

Remember this is newbie ramblings so i Hope i dont send you off on the wrong
track
Have fun
Barry

"barnstar" wrote:

Hi I am quite new to Access but I am desperate to learn as much as I can as
fast as I can.

I am currently working on automating an annual leave process at work & am
struggling & need help.

My problem is that I want the user to complete a form selecting the date(s) &
time(s) of leave they require. The leave pot is in half hour slots for e.g.
8:00 - 8:30 & so on. There would be a % of leave given on each half hour
which is calculated against a staff in post figure.

Once the user submits the form the db would automatically check the slots for
each half hourly slot for the time they requested off & return an immediate
response.

I hope somebody can help me with this problem & it would be much appreciated.

Thanks in advance

.