G
Guest
I have the following problem.
In a database, I want to keep records as historic, before making any changes
to them (historic in the same table). One of these fields is number (primary
ID) and part of one to many relationship (one side) with referential
integrity ON (update, delete ON). Before pasteappend I use a macro that sets
a new value to the ID and then append the new record (so that the new record
keeps the old value from the Id). The problem is that due to referential
integrity:
1. If cascaded updates is ON then all related records change their ID
2. if Off I can't change the ID of the historic due to presence of related
records.
So I can't do anything.
Because the whole procedure applies to many tables, I have designed a
generic macro for all I don't want to use an append query (by bypassing the
primary key) and macro because I have to make one for each table.
Yet I can't disable ref integrity because I need cascaded deletes.
I don't want to keep the historic data to another table because I change the
table structure often and because the current records are not many.
Is there a solution???
I have thought some work-throughs:
1. After pasteappend focus mustn't go to appended record, so changes are
made to the old one (as far as I know this is done through an append query,
which doesn't suite my needs)
2. It could be done by disabling ref integrity and resume after append. It
could be done easily by using a query updating mSysRelationships, but it is
read only. Could it be changed to read/write???
3. (wouldn't preffer it cause it has been since '95 I fiddled with VB).
Before append programmaticaly disable ref integrity for that relationship,
but I don't know DAO. Hence, how is this done? does the expression accept
wildcards so as to write a generic function for all tables according with the
opened form?
4. As above, disable ref int through data definition query (though I can't
find a corresponding sql statement)
5. In case none of the above can be done, is there a way in an appent query,
the appendto field to be calculated from an expression in a builder??
Any possible help is welcome. This issue has been bothering me for more than
3 days.
PS. Forgive me for the length of the post.
In a database, I want to keep records as historic, before making any changes
to them (historic in the same table). One of these fields is number (primary
ID) and part of one to many relationship (one side) with referential
integrity ON (update, delete ON). Before pasteappend I use a macro that sets
a new value to the ID and then append the new record (so that the new record
keeps the old value from the Id). The problem is that due to referential
integrity:
1. If cascaded updates is ON then all related records change their ID
2. if Off I can't change the ID of the historic due to presence of related
records.
So I can't do anything.
Because the whole procedure applies to many tables, I have designed a
generic macro for all I don't want to use an append query (by bypassing the
primary key) and macro because I have to make one for each table.
Yet I can't disable ref integrity because I need cascaded deletes.
I don't want to keep the historic data to another table because I change the
table structure often and because the current records are not many.
Is there a solution???
I have thought some work-throughs:
1. After pasteappend focus mustn't go to appended record, so changes are
made to the old one (as far as I know this is done through an append query,
which doesn't suite my needs)
2. It could be done by disabling ref integrity and resume after append. It
could be done easily by using a query updating mSysRelationships, but it is
read only. Could it be changed to read/write???
3. (wouldn't preffer it cause it has been since '95 I fiddled with VB).
Before append programmaticaly disable ref integrity for that relationship,
but I don't know DAO. Hence, how is this done? does the expression accept
wildcards so as to write a generic function for all tables according with the
opened form?
4. As above, disable ref int through data definition query (though I can't
find a corresponding sql statement)
5. In case none of the above can be done, is there a way in an appent query,
the appendto field to be calculated from an expression in a builder??
Any possible help is welcome. This issue has been bothering me for more than
3 days.
PS. Forgive me for the length of the post.