boblife42
06-19-2008, 10:44 AM
I have a combo box with three choices from a value list, 8 Hours, 10 Hours, or Custom. I have one table that has the following fields, EmployeeNumber, 8HourInAm, 8HourOutAM, 8HourInPM, 8HourOutPM, 10HourInAm, 10HourOutAM, 10HourInPM, 10HourOutPM, CustomInAm, CustomOutAM, CustomInPM, CustomOutPM.
What I was trying to do is when the user selects 8 hours in the combo box on the form the time entered in the table for 8HourInAm, 8HourOutAM, 8HourInPM, 8HourOutPM is entered in the InAmTime, OutAmTime, InPmTime, OutPmTime fields on the form, for that specific user.
Here is the code I have so far:
Private Sub cbo_HoursPerDay_AfterUpdate()
If cbo_HoursPerDay.RowSource = "8 Hours" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['8HourInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['8HourOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['8HourInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['8HourOutPM']
End If
If cbo_HoursPerDay.RowSource = "10 Hours" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['10HourInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['10HourOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['10HourInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['10HourOutPM']
End If
If cbo_HoursPerDay.RowSource = "Custom" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['CustomInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['CustomOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['CustomInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['CustomOutPM']
End If
End Sub
____________________________________
I am sure I need a lookup to match the employee number on the form to the employee number in the table. Thank you for any help that you can give, I am relatively new at VBA code.
What I was trying to do is when the user selects 8 hours in the combo box on the form the time entered in the table for 8HourInAm, 8HourOutAM, 8HourInPM, 8HourOutPM is entered in the InAmTime, OutAmTime, InPmTime, OutPmTime fields on the form, for that specific user.
Here is the code I have so far:
Private Sub cbo_HoursPerDay_AfterUpdate()
If cbo_HoursPerDay.RowSource = "8 Hours" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['8HourInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['8HourOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['8HourInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['8HourOutPM']
End If
If cbo_HoursPerDay.RowSource = "10 Hours" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['10HourInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['10HourOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['10HourInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['10HourOutPM']
End If
If cbo_HoursPerDay.RowSource = "Custom" Then
Me.InAmTime.Value = tbl_EmployeeShiftInformation.['CustomInAM']
Me.OutAmTime.Value = tbl_EmployeeShiftInformation.['CustomOutAM']
Me.InPmTime.Value = tbl_EmployeeShiftInformation.['CustomInPM']
Me.OutPmTime.Value = tbl_EmployeeShiftInformation.['CustomOutPM']
End If
End Sub
____________________________________
I am sure I need a lookup to match the employee number on the form to the employee number in the table. Thank you for any help that you can give, I am relatively new at VBA code.