I'm having an issue with the Error 3022 per duplicate records. I know for a fact that I don't have duplicate records and for some reason it is telling me I do. I've changed the primary key to autonumber, all the rest of the fields to Yes (Duplicate is OK) to building a relationship between the tables. Nothing seems to work. Here is a sample of my code:
Dim dbs As DAO.Database
Dim rsClassRoom As DAO.Recordset
Dim rsTempPhase As DAO.Recordset
Dim rsHeadcountbyCourses As DAO.Recordset
Dim rsTemp_Headcount1 As DAO.Recordset
Dim rsScheduleCourses As DAO.Recordset
Dim rsCourses As DAO.Recordset
strClassroom = "SELECT * FROM [tblTraining_Rooms] ORDER BY tblTraining_Rooms.TimeEnd"
Set rsClassRoom = dbs.OpenRecordset(strClassroom)
rsClassRoom.MoveFirst
' Start adding records in tblSchedule_Courses table
strSQL1 = "SELECT * FROM [tblSchedule_Courses]"
Set rsScheduleCourses = dbs.OpenRecordset(strSQL1)
'Adding code to tblSchedule_Course
strSQL3 = "SELECT * FROM [Temp_Course_Headcount] ORDER BY CourseID"
Set rsTemp_Headcount1 = dbs.OpenRecordset(strSQL3)
Course = rsTemp_Headcount1!CourseTitle
strCourses = "SELECT * FROM [tblCourses] WHERE [CourseTitle] = '" & Course & "'"
Set rsCourses = dbs.OpenRecordset(strCourses)
rsScheduleCourses.AddNew
rsScheduleCourses![Courses] = "Overview"
rsScheduleCourses![Duration] = rsCourses![TotalClassroomDuration]
rsScheduleCourses![SchedDate] = DateFrom
rsScheduleCourses![StartTime] = TimeBeg
rsScheduleCourses![EndTime] = DateAdd("n", rsCourses![TotalClassroomDuration], rsScheduleCourses![StartTime])
TimeBeg = rsScheduleCourses![EndTime]
rsScheduleCourses![EmpCount] = rsTemp_Headcount1![HeadcountTotalByCourse]
rsScheduleCourses![Classroom] = "Cafeteria"
rsScheduleCourses![Shifts] = strShifts
rsScheduleCourses![Phase] = Forms![frmSchedulerDialog]![cmbPhase]
rsScheduleCourses.Update
rsScheduleCourses.AddNew
rsScheduleCourses![SchedDate] = DateFrom
rsScheduleCourses![Courses] = "Team Huddle"
rsScheduleCourses![StartTime] = TimeBeg
rsScheduleCourses![EndTime] = DateAdd("n", 15, rsScheduleCourses!StartTime)
rsScheduleCourses![Duration] = 15
rsScheduleCourses![Shifts] = strShifts
rsScheduleCourses![Phase] = Forms![frmSchedulerDialog]![cmbPhase]
rsScheduleCourses.Update
I might have missed adding something in this area, but for some reason, the code above is used in 2 locations of the OK button click procedure. It would give error 3022 and no reason I can think of.
I really need to fix this to enjoy my holiday. Pls Helpppppppp!