Good day Everyone,
I am looking for some help with my vacation database attached. I have spent alot of time tring to reach my
resoultion using queries but that seems like it is not working. I just need to be given some direction in how
I should go about this. I am creating a vaction database for 600 employees that only permits so many people
off per day in any given tourband(which is various intervals throughout the day.IE 12:00AM to 7:00AM is
TB10).I think I have to use VBA and I am not sure where or how to begin. Bacically what I am tring to find
is a treshold(maxium number of people off) for a given Tourband(recgonized in a table as a field name
"curtour"). In order to find this treshold I have to Count all the people in the given Tourband and multiply
it by 4%. This result will give us the maxium amount off people permitted off per day. To add a litte more
confusion, each person has a tourband and a divison(which can be noted as TS, SUT or FLR, and this value is
found in the table tblemployee under "curpos"). I am only concerned with the with the TS division when it
comes to Tourband, with the other Divisions(I.E SUT, FLR) their threshold will be set at an overall basis. It
will have to look like this
TB Avail = Count([Empid], "tblemployee", [curtour] = [forms]![frmemployee]![curtour])
ForcastAbsent = TB Avail * .10
TB Avail - ForecastAbsent - ExistingVacation = TrueAvail
TB Avail --> The Sum of people within the current tourband
ForecastAbesent --> Is the predicted people that will not be at work today this is obviously approx.
ExistingVaction --> People who already have that certain day off, scheduled in the past
I am think this code with have to go under the Confirm button on my frmemployee form. So I am thinking it
will go like this,
If Me.[curtour] = TB10 or TB08 and Me.[curpos] = TS Then
Let ExistingVacation = DCount([Empid], "tblvacation", [curtour] = [forms]![frmemployee]![curtour])
Let ExistingFloater = DCount([Empid], "tblfloater", [curtour] = [forms]![frmemployee]![curtour])
Let TB Avail =DCount([Empid], "tblemployee", [curtour] = [forms]![frmemployee]![curtour])
Let ForcastAbsent = TB Avail * .10
Let TrueAvail = TB Avail - ForecastAbsent
Let Threshold = TrueAvail * .04
If Threshold > (ExistingVacation + ExistingFloater) Then
Msgbox("Sorry no vacation time for this day")
exit sub
else
DoCmd.RunSQL "INSERT INTO tblvacation (empid, vhours, vdate, curtour, curpos) Values
(forms!frmemployee!empid, forms!frmemployee!txtvhours, forms!frmemployee!txtvdate, forms!frmemployee!curtour,
forms!frmemployee!curpos);"
Exit
Endif
Any advice would be greatly appreciated.
durdle
________
starcraft ii replays
I am looking for some help with my vacation database attached. I have spent alot of time tring to reach my
resoultion using queries but that seems like it is not working. I just need to be given some direction in how
I should go about this. I am creating a vaction database for 600 employees that only permits so many people
off per day in any given tourband(which is various intervals throughout the day.IE 12:00AM to 7:00AM is
TB10).I think I have to use VBA and I am not sure where or how to begin. Bacically what I am tring to find
is a treshold(maxium number of people off) for a given Tourband(recgonized in a table as a field name
"curtour"). In order to find this treshold I have to Count all the people in the given Tourband and multiply
it by 4%. This result will give us the maxium amount off people permitted off per day. To add a litte more
confusion, each person has a tourband and a divison(which can be noted as TS, SUT or FLR, and this value is
found in the table tblemployee under "curpos"). I am only concerned with the with the TS division when it
comes to Tourband, with the other Divisions(I.E SUT, FLR) their threshold will be set at an overall basis. It
will have to look like this
TB Avail = Count([Empid], "tblemployee", [curtour] = [forms]![frmemployee]![curtour])
ForcastAbsent = TB Avail * .10
TB Avail - ForecastAbsent - ExistingVacation = TrueAvail
TB Avail --> The Sum of people within the current tourband
ForecastAbesent --> Is the predicted people that will not be at work today this is obviously approx.
ExistingVaction --> People who already have that certain day off, scheduled in the past
I am think this code with have to go under the Confirm button on my frmemployee form. So I am thinking it
will go like this,
If Me.[curtour] = TB10 or TB08 and Me.[curpos] = TS Then
Let ExistingVacation = DCount([Empid], "tblvacation", [curtour] = [forms]![frmemployee]![curtour])
Let ExistingFloater = DCount([Empid], "tblfloater", [curtour] = [forms]![frmemployee]![curtour])
Let TB Avail =DCount([Empid], "tblemployee", [curtour] = [forms]![frmemployee]![curtour])
Let ForcastAbsent = TB Avail * .10
Let TrueAvail = TB Avail - ForecastAbsent
Let Threshold = TrueAvail * .04
If Threshold > (ExistingVacation + ExistingFloater) Then
Msgbox("Sorry no vacation time for this day")
exit sub
else
DoCmd.RunSQL "INSERT INTO tblvacation (empid, vhours, vdate, curtour, curpos) Values
(forms!frmemployee!empid, forms!frmemployee!txtvhours, forms!frmemployee!txtvdate, forms!frmemployee!curtour,
forms!frmemployee!curpos);"
Exit
Endif
Any advice would be greatly appreciated.
durdle
________
starcraft ii replays
Attachments
Last edited: