Backup two tables from a network access db to a local db copy

I have an access database on a network that I need to copy 2 tables (say table1, table2) to local copy of the exact database.  We need this as the network goes down frequently and work halts.  I want a user to be able to click a button on a form and have them copy the updated network database tables to the older outdated tables on a local computer.  Any suggestions?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

On the button's OnClick event you can put:

DoCmd.TransferDatabase acExport, "Microsoft Access", _
    "C:\PathAndNameOfDatabaseToExportTo.mdb", acTable, "NameOfTableToBeExported", _

In your case the names of the source and destination tables will probably be the same.  Do this for each table you want to export.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCCommented:
Check out my article on temporary tables.

updatetemptable "LocalTableName", "linkedTableName", True, 0
BOULMANAuthor Commented:
The above code looks like it will work fine.  Will this overwrite the "old" table info each time I use this?  I won't be able to test that until monday.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Dale FyeOwner, Developing Solutions LLCCommented:
My UpdateTempTable function does, with the other, you will first need to test to see whether the table already exists.  And if it does, delete before running the transferdatabase method.

My UpdateTempTable function also will let you save the new table to a temporary database on the same path as your application, and will automatically link the table from that temporary database to your application, which will avoid some of the bloating issues associated with temporary tables.
Jeffrey CoachmanMIS LiasonCommented:
Just a note, ...any system like this is inherently susceptible to failures.
I mean if: "the network goes down frequently and work halts"...

...Then whats to say that the network won't go down in the middle of your"Copy" operation.
Then what?!?!
Half the data is copied, and you loose the original?

You need "Rock Solid" error handling and an "Iron-Clad" "Rollback" system.
(remname the static tables, Import the new tables, verify the copy, delete the originals)
In case of a failure in the middle of the "Copy" operation, your system must be able to delete the incomplete copied table, then restore/rename the original table...
Do you have something like this in place?

It's a shame to have to go through all of this trouble for a "iff-y" network that can't fulfill one of the most basic requirements of a network...

The same time and energy might be better spent beefing up the network...


Jeffrey CoachmanMIS LiasonCommented:
...I see that fyed has already touched on this...

Please continue on with the previous experts...


BOULMANAuthor Commented:
Sorry for the delayed response. But IrogSinta's code works as needed.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.