Solved

Access 2010: Merge Database with the same structure

Posted on 2011-09-30
16
282 Views
Last Modified: 2012-05-12
So I had to provide my staff with a copy of Access form/database (cant use serever) and merge their input from time to time. As my form contains several multiple fields I cant do that through 'ammend query'. All my tables are connected to the main one through the same key (star )
I googled a solution below however it doesnt include databases with relationships:
http://ilovecoding.co.uk/blog/ms-access/merge-multiple-ms-access-databases-into-a-single-one/

For now Im just copy pasting but that obviously takes too much time...

Can somebody provide me an example of a similar VBA solution?
0
Comment
Question by:Ianski
  • 9
  • 7
16 Comments
 
LVL 39

Expert Comment

by:als315
Comment Utility
You can assign to every user's base some unique number, which will be added to main DB.
For example: First user will have ID =1, Second - 2 etc.
Main table should have index form this ID (user) and record ID.
Example have 2 tables and 2 append queries. You can also update records, if you like it with update queries
DB27373708.accdb
0
 

Author Comment

by:Ianski
Comment Utility
Yup thats correct however as I wrote cant use append (or ammend :P ) queries cause I have multipple input fields. Besides Id like to join 2 separate databases not tables if possible.
Looking for VBA automation
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
May be you can show example of your Dbs? What is joining of databeses? Usually joining means adding data from "user's" databases to "central".
You can use code from your example for automation, but you should prepare data for joining.
0
 

Author Comment

by:Ianski
Comment Utility
thats my first project in Access so sry if I didnt explain correctly.
So by prepare data for joining do you mean linking databases?
14064202.jpg
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
No, I mean adding some unique IDs for identification of source DB. If you have many tables - you should add these two fields (user ID and Record ID) to every table in main DB.
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
I can't understand how you can copy/paste data from user DB to main. You shoud also correct references i¿ you have some autonumber IDs
0
 

Author Comment

by:Ianski
Comment Utility
right, imagine one of my engineers wants to work from home this week. As I cant get server, I send him an empty database (empty copy of master) so that he could type in another strategy in it. When he finish he send it back to me and Id merge it with master one.
So id have to copy all existing rows from all tables in his version to master (no dupes) starting from one row in master table 'textbox'
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
I think you could have too many problems with this approach.
For example:
During homework user will add some new records to table textbox and then delete one or more (let Strategy will be 10,11,13,15). In all other tables you have reference to this table. When you are adding data to main table, autonumber field will be (if your textbox table will be unchanged) 10,11,12,13. But references in other tables will be unchanged and you should have method for correcting them. And you will always have problems when home users will be more then one.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Ianski
Comment Utility
users get a form with empty database and they add one strategy per their form/database eg one main primary key in textbox. There is no autonumber - primary key is equal to unique predefined strategy number.
Im sure there is a way to connect via ADODB or something just to copy all rows from one database to another one /no dupes/
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
It is not a problem, if references will not be changed.
Can you upload empty DB (central) with tables and another one with one strategy filled (with sample data)?
0
 

Author Comment

by:Ianski
Comment Utility
didnt upload any pics but commented them out
login/pass: jan

cheers
2dbs.zip
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
Many times on EE was stated - it is not good idea to have lookup fields in tables.
Method in included example can't be used with such tables.
Problem tables:Maintenance Activities, SAP Implementation Assurance, SAP Implementation Normal. May be better will be add separate tables for fields with lookup fields.
Idea is in using one query for all tables. Tables are listed in table TablesList. Problem tables are commented with '.
Open form Form1, set name of second db (should be in current DB path) and press button.
Version-A.zip
0
 

Author Comment

by:Ianski
Comment Utility
thanks for help. Ill analyse it tomorrow. Any idea how else could I sort out my lookup fields?
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
This is not pure lookup, but multivalued field - Failure modes covered - in table Maintenance Activities. Are you sure it is nesessary? You can't use such field in append or update query.
0
 

Author Comment

by:Ianski
Comment Utility
OK thanks. looks good. Could you show me on one of those tables how would you do sort out lookup field using separate table? Or should I start a new question?
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
Due to EE rules you should start new question.
But, as I've mentioned in last comment, problem is in multivalued lookup fields, not in simple lookup fields.
You can sort values in form without doing it in table.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now