Hi,
I'm working with Access 2010, though I'm sure advice from Access 2007 would be applicable.
Basically, I have three tables:
tblStudent
tblService
tblStudentService (junction table between tblStudent and tblStudentService)
My tblService has almost 3,000 records. Most of these records, unfortunately are duplicates. They are the same service (name, time, date, category). However they have different ServiceID's, which is the primary key of tblService, so Access thinks they're different.
My tblStudentService is made up of StudentServiceID (pk of that table), StudentID (fk) and ServiceID (fk). This junction table now has the wrong information because of the duplicate ServiceID's. Instead of having 100 students enrolled in the same ServiceID (which should be the case), those same 100 students are enrolled in 100 different ServiceID's (though it is actually the same service in every other field).
What I have to do now is look at all my services in tblService and figure out which ones are the same in every field but the ServiceID. Those will be the duplicates. Then I have to take the first ServiceID that is not a duplicate and plug it into the ServiceID (fk) field in my tblStudentService. Then I have to delete the duplicate service from tblService.
I have between 3,000 and 4,000 of these to correct, so doing all of them manually would take quite a bit of time. Would anyone be able to suggest a function or some code that would automate at least some of the process? If anyone has any advice, I'd be very grateful. Thank you!
I'm working with Access 2010, though I'm sure advice from Access 2007 would be applicable.
Basically, I have three tables:
tblStudent
tblService
tblStudentService (junction table between tblStudent and tblStudentService)
My tblService has almost 3,000 records. Most of these records, unfortunately are duplicates. They are the same service (name, time, date, category). However they have different ServiceID's, which is the primary key of tblService, so Access thinks they're different.
My tblStudentService is made up of StudentServiceID (pk of that table), StudentID (fk) and ServiceID (fk). This junction table now has the wrong information because of the duplicate ServiceID's. Instead of having 100 students enrolled in the same ServiceID (which should be the case), those same 100 students are enrolled in 100 different ServiceID's (though it is actually the same service in every other field).
What I have to do now is look at all my services in tblService and figure out which ones are the same in every field but the ServiceID. Those will be the duplicates. Then I have to take the first ServiceID that is not a duplicate and plug it into the ServiceID (fk) field in my tblStudentService. Then I have to delete the duplicate service from tblService.
I have between 3,000 and 4,000 of these to correct, so doing all of them manually would take quite a bit of time. Would anyone be able to suggest a function or some code that would automate at least some of the process? If anyone has any advice, I'd be very grateful. Thank you!