HI Wayne
I appreciate your help but your code seem to do more than I need, my fault for not being clear enough. Here is what I am trying to do: I have a master table (say tblMaster) containing a large number of records, mainly name and city. I need to insert records from the master table to secondary tables (tblsecondary,1,2...5). At the end of the process each secondary table should have the same number of records total (say 500) and the same number of records selected from each city. So tblSecondary1 will have 100 records from NY, 100 records from LA, etc..., tblsecondary2 will have 100 from NY (not the same as tblsecondary1), 100 for LA and so on. Does that make more sense?
I tried also using insert queries with TOP and excluding already selected records using NOT IN (select statement) but it becomes very long and clumsy.
Thanks for helping.