1

Re: Deleting records via Access

Hello,
I've imported data with the import tool and now realised, that I have to delete quite some of them. They are too many, that it would be worth doing it manually. So I wonder, if it possible to do it from Access?
I can create a query in Access, which gives me all the Taxon_Occurrence-Keys, which I would have to delete. So I would delete all recordsets from the table "dbo_Taxon_Occurrence", which have these Taxon_Occurrence_Keys. I then have to delete all relating datasets from all tables, where the Taxon_Occurrence_Key is used as foreign key? I've found so far "dbo_TAXON_OCCURRENCE_DATA", "dbo_TAXON_OCCURRENCE_RELATION" and "dbo_TAXON_OCCURRENCE_SOURCES". Are there any more?
I would then delete all datasets from the table "dbo_Sample", of which the Sample_Key is not used any longer as foreign key in "dbo_Taxon_Occurrence". Then I would delete all relating datasets from all tables, where the Sample_Key is used as foreign key. So far I've found  "dbo_SAMPLE_DATA", "dbo_SAMPLE_RECORDER", "dbo_SAMPLE_RELATION", "dbo_SAMPLE_SOURCES" and "dbo_SAMPLE_TYPE". Are there any more?
I would then delete all datasets from the table "dbo_SurveyEvent", of which the Survey_Event_Key is not used any longer as foreign key in "dbo_Sample". I would delete all relating datasets from all tables, where the Survey_Event_Key is used as foreign key. So far I've found "dbo_SURVEY_EVENT_OWNER", "dbo_SURVEY_EVENT_RECORDER" and "dbo_SURVEY_EVENT_SOURCES". Are there any more?
Has anybody done something similar? Is there an easier way of doing that?

Thanks for your help,
Wolfgang

2

Re: Deleting records via Access

There is another way of doing this which may be worth a try. There is a Batch Update which is designed to do the whole thing. It works on taxon_Occurrences which have specific text in the comment field. What you would need to do is to update the comment field  for the Taxon_Occurrences you wish to delete. You can do this in Access once you have identified the TOC keys involved. For these keys replace what is in the comment field with something unque   say  DELETE7022012. then use the Batch Update Del2 which will delete all these records and everything which goes with them. Then it deletes  the Samples and  Events which have nothing left in them after the Taxon_Occurrences are deleted.

It is possible to do in Access, but you have to do it in reverse order to avoid problems with referential integrity.  You need to delete Taxon_Determination, Taxon_Occurrence_data, Taxon_Occurrence_Relation and Taxon_Occurrence_Sources first. Only then you can delete Taxon_Occurrence. Access will not do deletes with joined tables, so I would normally update a field (Changed_By is a good bet), with the word  'DELETE'.  Then use a delete query on the table to delete anything with 'DELETE' in this field.  If you first update the Changed_By field to DELETE in Taxon_Occurrence for the Records you don't want. Link this to the other tables one by one and update their Changed_By to DELETE . Then go through them one by one in the order specified above doing the deletes. If the delete fails on Taxon_Occurrence this will tell you if there are other linked tables which you will need to do first.

Once you have got rid of the Taxon_Occurrences you will find that there are two Batch updates which do the rest for you. Look in the Delete menu in Batch Updates . First run the one which deletes the Samples with no occurrences. Then the one which  deletes Events with no samples. Remember that these updates will  look at everything and not  just at the sample for the taxon occurrences you have deleted.

Mike Weideli

3

Re: Deleting records via Access

Thank you very much Mike. That way was much easier!

Wolfgang