I have a query called "Last Race" that looks at a table containing information on every race every racehorse in my database has ever run. It gets the most recent race for each horse. That query is then used as input to a lot of other queries that pick up information from other tables and do a lot of calculations.
Now I want to do the same exact thing for a horse's last 5 races.
Writing the query to get the last 5 races was rather complex. So instead I exported the races table to an Excel spreadsheet where I have a little routine that made it easy for me select the last 5 races for each horse. Then I imported the spreadsheet back to a table called "Last 5 Races". Now I have the data I need.
All the field names for Last Race query and Last 5 Races table are the same.
You would think it would be easy to substitute one table as input for the other and just run the "last 5 races" table through the same process, but it doesn't work that way.
Various calculations in these queries refer to fields that are prefixed by "Last Race" so the queries know where the original source was in case of duplicate names. That means if I substitute the "Last 5 Races" table at the start of this process a bunch of fields will not be found downstream. I know, I tried it.
I thought that maybe I could rename my Last Race query to something else and rename my Last 5 Races table to Last Race and fool it. That would be a nice idea in "theory". However, the times I renamed a query I either destroyed a bunch of linkages or all the linkages were renamed with it. In this case one would be a disaster and the other a waste of time. So that won't work.
The other possibility is to duplicate every single query that uses Last Race and create a new one that will use Last 5 Races instead and also change all the field names referenced so they point to right place. That's a monumental effort and leaves me screwed long term because any time I change something in one I will have to change it both places.
Anyone have an ideas?