Hi DCB - Here is the code for all combos which update the Units Subform. I did change my Table name in SQL and am wondering would that have anything to do with it. But then i'm stumped as using a numerical value for employeeid works great but if i want to use a value like b004 as the employeeid, it will not show the employee. The SQL Field is varchar(50)
Private Sub CboYear_AfterUpdate()
Me.CboUnit.RowSource = "SELECT DISTINCT LK_Safety_History.UnitID, Unit.Location " _
& "FROM LK_Safety_History INNER JOIN Unit ON LK_Safety_History.UnitID = Unit.UnitID " _
& "WHERE [LK_Safety_History].[YearID] = " & Me.CboYear & _
" ORDER BY Unit.Location"
Me.CboUnit = Me.CboUnit.ItemData(0)
CboUnit = Null
CboDiscipline = Null
CboEmployee = Null
Me.Units.Form.RecordSource = "SELECT DISTINCT LK_Safety_History.Safety_History_ID, LK_Safety_History.YearID, LK_Safety_History.EHS_CourseID, LK_Safety_History.Expiry, LK_Safety_History.Renewal, LK_Safety_History.EmployeeID, LK_Safety_History.UnitID, LK_Safety_History.DisciplineID, LK_Safety_History.Completed FROM LK_Safety_History " _
& "WHERE LK_Safety_History.[YearID] = " & Me.CboYear _
& " ORDER BY LK_Safety_History.YearID"
End Sub
Private Sub CboUnit_AfterUpdate()
Me.CboDiscipline.RowSource = "SELECT DISTINCT LK_Safety_History.DisciplineID, Discipline.Discipline " _
& "FROM LK_Safety_History INNER JOIN Discipline ON LK_Safety_History.DisciplineID = Discipline.DisciplineID " _
& "WHERE [LK_Safety_History].[YearID] = " & Me.CboYear _
& " AND [LK_Safety_History].[UnitID] = " & Me.CboUnit _
& " ORDER BY Discipline.Discipline"
Me.CboDiscipline = Me.CboDiscipline.ItemData(0)
CboDiscipline = Null
CboEmployee = Null
Me.Units.Form.RecordSource = "SELECT DISTINCT LK_Safety_History.Safety_History_ID, LK_Safety_History.YearID, LK_Safety_History.EHS_CourseID, LK_Safety_History.Expiry, LK_Safety_History.Renewal, LK_Safety_History.EmployeeID, LK_Safety_History.UnitID, LK_Safety_History.DisciplineID, LK_Safety_History.Completed FROM LK_Safety_History " _
& "WHERE LK_Safety_History.[YearID] = " & Me.CboYear _
& " AND [LK_Safety_History].[UnitID] = " & Me.CboUnit _
& " ORDER BY LK_Safety_History.UnitID"
End Sub
Private Sub CboDiscipline_AfterUpdate()
Me.CboEmployee.RowSource = "SELECT DISTINCT LK_Safety_History.EmployeeID, Employees.Employee " _
& "FROM LK_Safety_History INNER JOIN Employees ON LK_Safety_History.EmployeeID = Employees.EmployeeID " _
& "WHERE [LK_Safety_History].[YearID] = " & Me.CboYear _
& " AND [LK_Safety_History].[UnitID] = " & Me.CboUnit _
& " AND [LK_Safety_History].[DisciplineID] = " & Me.CboDiscipline _
& " ORDER BY Employees.Employee"
Me.CboEmployee = Me.CboEmployee.ItemData(0)
CboEmployee = Null
Me.Units.Form.RecordSource = "SELECT DISTINCT LK_Safety_History.Safety_History_ID, LK_Safety_History.YearID, LK_Safety_History.EHS_CourseID, LK_Safety_History.Expiry, LK_Safety_History.Renewal, LK_Safety_History.EmployeeID, LK_Safety_History.UnitID, LK_Safety_History.DisciplineID, LK_Safety_History.Completed FROM LK_Safety_History " _
& "WHERE LK_Safety_History.[YearID] = " & Me.CboYear _
& " AND [LK_Safety_History].[UnitID] = " & Me.CboUnit _
& " AND [LK_Safety_History].[DisciplineID] = " & Me.CboDiscipline _
& " ORDER BY LK_Safety_History.DisciplineID"
End Sub
Private Sub CboEmployee_AfterUpdate()
Me.Units.Form.RecordSource = "SELECT DISTINCT LK_Safety_History.Safety_History_ID, LK_Safety_History.YearID, LK_Safety_History.EHS_CourseID, LK_Safety_History.Expiry, LK_Safety_History.Renewal, LK_Safety_History.EmployeeID, LK_Safety_History.UnitID, LK_Safety_History.DisciplineID, LK_Safety_History.Completed FROM LK_Safety_History " _
& "WHERE LK_Safety_History.[YearID] = " & Me.CboYear _
& " AND [LK_Safety_History].[UnitID] = " & Me.CboUnit _
& " AND [LK_Safety_History].[DisciplineID] = " & Me.CboDiscipline _
& " AND [LK_Safety_History].[EmployeeID] = " & Me.CboEmployee _
& " ORDER BY LK_Safety_History.EmployeeID"
End Sub