dewildpup said:
The Normalized table is built on the fly.
That's actually an oxy-moron. If in the process of changing your data you need to change the
schema of your database, that by definition is non-normalized. I.e. "data entry" should not require changes in database design.
The fields you want to "add on the fly" are actually data. It's data because it's entered by your users.
Might I suggest a design that I think will work? It's only a variation form Remou's original reply.
EarnCodes
EarCode
EarName
Deductions
EarCode---------|-- these two fields are the primary key
DeductionID-----|
Apply (boolean)
DeductionCodes
DeductionID
DeductionCode
Description
So you tables with data would be:
EarCode EarName
100 Salary
105 Travel
DeductionID DeductionCode Description
035 TOC Taxes on Car
EarCode DeductionID Apply
100 035 Y
105 035 N
One thing you need to do is when the user creates a new DeductionCode record, you need to add one new Deduction record for each existing EarningCode (conversely you would need to delete related Deductions records if a DeductionCode is deleted).
One of the nice things about using this design is you don't have to create controls on the fly - an ordinary bound form will do it for you. I can envision having a main form for the Earning Codes, and a subform for the Deductions records. Since "Apply" is a boolean field, Access would automatically render a checkbox for you (but if you really want the user to pick "Yes" or "No" you could also make a dropdown). If the user creates (or deletes) a deduction on the fly, you would need to requery your subform.
If you really want your deduction codes to
appear like columns you could probably do that with a pivot table.
Regarding "thinking inside the box", encouraging you to follow proven best practices does not mean we are lacking in imagination. I know exactly what you are trying to achieve, and why, and I could tell you how to do it, and it would even work. But it would be a poorer, less flexible design than the relational/normalized schema we are trying to encourage you to adopt.