Web Development
3 replies
by bob sellman
If I understand your requirements, you basically want to add a complete set of records to a table for a new year and the number of new records for each client will depend upon whether the client is Q, S-A, or A.
Here's the concept of how I would approach this, assuming that you will insert a new record to the table as needed. (You could test and even use a temporary table for creating the new records, then append the entire new table to the existing table.)
First, create a recordset froma query which lists all clients and all records for the current year. The relationship is all clients and any current year records, so that all clients are returned in the query, even if no records were entered for the current year for a client. Sort this recordset by client and date field.
Set variables for the client ID, the indicator (Q, S-A, A), the date, and a counter. Read each record. At the first record for a client, determine the number of records to add (4, 2 or 1), and check the date. If it's valid for the period, add a year, and insert a new record into the table with the appropriate data. If it's not the right period, insert a new record with the right date, then look at the current data again. If you're still not atthe right date, insert another new record with the right date. Keep looping until you reach data with the correct date for the period.
When the client ID changes, make sure you write any missing records before proceeding to process the new vendor.
What I'm talking about is basically a for to next loop within another for to next loop. The number of iterations of the inner loop will be controlled by the valuation (Q,S-A,A). You might need a flag so that if the inner loop goes to a new record that has a new vendor, the outer loop will not increment (or you just go back to an appropriate point in the inner loop).
Hope this helps.
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending