nathanstevenson
IS-IT--Management
Greetings,
I have 2 databases with the same tables, the same field setups and the same relationships. The first database records all historical data (called A). The second one is a staging database, which records one month's worth of data (called B). I am trying to build a program to import the monthly DB into the historical DB.
As I am in the process of switching over from an old process to this new all-Access process, I want to have this distinction so that the primary DB only contains consistent, robust data with very few inconsistencies.
So the question is.. how do I compare records in db B, with records in db A, if they are the same assign them Primary Key from db A, if not, append. My guess is that I make one HUGE query that creates a new table, with all fields from all tables. Then somehow compare the fields in this "Import" table to each record in each table in A, where there is a match, subset of data in "Import" table is assigned key from A. If there is no match, checks to see how many records in tbl A, and assigns ID, as if it was appended. But it also needs to check internally, to see what num we are at (in terms of appending), because all the keys need to exist BEFORE the data can be imported into the tables, or else referential integrity on the primary DB will be compromised.
E.G. to import you "start at the top", and add in your records as you go, table by table. This way you can maintain integrity.
Again, I am stumped when it comes to comparing tblA, rec1 with tblB, rec1. How is this done programmatically? I have had a bit of experience with VBA in Excel, but I am having difficulties even addressing the different objects (rows, cells, tables etc) in Access. Also I would far prefer to use recordsets as opposed to the macro type code, cause I need to learn!
Any help would be highly appreciated!
Nathan
I have 2 databases with the same tables, the same field setups and the same relationships. The first database records all historical data (called A). The second one is a staging database, which records one month's worth of data (called B). I am trying to build a program to import the monthly DB into the historical DB.
As I am in the process of switching over from an old process to this new all-Access process, I want to have this distinction so that the primary DB only contains consistent, robust data with very few inconsistencies.
So the question is.. how do I compare records in db B, with records in db A, if they are the same assign them Primary Key from db A, if not, append. My guess is that I make one HUGE query that creates a new table, with all fields from all tables. Then somehow compare the fields in this "Import" table to each record in each table in A, where there is a match, subset of data in "Import" table is assigned key from A. If there is no match, checks to see how many records in tbl A, and assigns ID, as if it was appended. But it also needs to check internally, to see what num we are at (in terms of appending), because all the keys need to exist BEFORE the data can be imported into the tables, or else referential integrity on the primary DB will be compromised.
E.G. to import you "start at the top", and add in your records as you go, table by table. This way you can maintain integrity.
Again, I am stumped when it comes to comparing tblA, rec1 with tblB, rec1. How is this done programmatically? I have had a bit of experience with VBA in Excel, but I am having difficulties even addressing the different objects (rows, cells, tables etc) in Access. Also I would far prefer to use recordsets as opposed to the macro type code, cause I need to learn!
Any help would be highly appreciated!
Nathan