chrispilie wrote:
> A user sets up a job with a StartDate and a Duration
(Weeks).
In your sample data, the StartDate value is always the same.
Which makes it seem like "StartDate" is an attribute of a Job.
Since we cannot see your schema, I do not know if that is correct.
But if it is, StartDate should be stored in the Job table (not
Productivity). By duplicating the StartDate value in every
Productivity record, the dates for a single "JobNumber" can easily
get out-of-synch.
> What would be Ideal is when the user goes to the
Productivity page, the change is
> recognized and the insert statement would run to update
duration changes if there
> are any and then the update statement would
progressively (possibly a loop
> incrementally 7 days) change the WeekEndingDates based
on the new StartDate.
If you are _only_ dealing with 7 day blocks, then the general
process comes down to two things:
1) Determine how existing record dates should be adjusted,
due to a change in start date
2) Determine how many records should be added/removed, due to
a change in duration
The first is just calculating the number of weeks difference
between the old and new start dates. You could use the DateDiff
function for this. Then adjust the existing dates using that offset
value in the dateAdd function
... SET WeekEndingDate = dateAdd('ww', numberOfweeksOffset,
WeekEndingDate)
To determine the number of weeks to add or remove, simply
compare the old and new duration values. Then add or remove records
as needed. The rest is just basic date calculations.
Bear in mind, this is all based on my very limited knowledge
of Access. It is distinctly possible there are better ways to
achieve this (even with MS Access). However, given its limitations
I suspect the final code will end up being more convoluted than if
you were using a fully featured database like MS SQL.
However, before you can write the sql, you need to nail down
all of the possible scenarios. Then determine how each and every
case should be handled according to your business rules. That is
something only you can do. It often helps to write out the logic
and individual steps in plain english first. Then convert it to
code and/or sql.
> There will be a need eventually to deploy a daily
options rather than weekly.
That is something you may want to consider that now, while
you are still in the design phase. Think about how easy or
difficult it would be to implement that change, given your current
structure.