TransferDatabase help

Michael Moore 21 Reputation points
2022-06-13T19:33:04.44+00:00

I have a MS Database that when I close the database, I want to export the main data table to a back-up database. Here is my VBA script -

destfilename = "PGA Matrix 6-2022 - REP VERSION.mdb"
destfileloc = "Z:\CSC\MMOORE\ACCESS\Backup\"
DoCmd.TransferDatabase acExport, "Microsoft Access", destfilename, acTable, "Main Data", destfileloc, False

This fails every time. Not sure what I'm doing wrong?

Microsoft 365 and Office | Access | Development
Developer technologies | Visual Basic for Applications
{count} votes

Answer accepted by question author
  1. Karl Donaubauer 2,691 Reputation points MVP
    2022-06-15T08:07:59.363+00:00

    Hi,

    You should always insert here the exact code you tried, the error number and the message you received. Otherwise it is difficult to find out where the problem is.

    Following your latest information, syntactically this should work:

    Dim strDestFullPath As String

    strDestFullPath = "Z:\CSC\MMOORE\ACCESS\Backup\PGA MATRIX 6-2022 Rep Version.accdb"

    DoCmd.TransferDatabase acExport, "Microsoft Access", strDestFullPath, acTable, "Main Data", "Main Data"

    If you still get an error it could e.g. be because the target drive is not accessible for Access. If you get something like that, test the code with a safe reachable path on C. If it works there and not with Z, then the problem is the access to the drive.

    Servus
    Karl
    Access News
    Access DevCon


6 additional answers

Sort by: Most helpful
  1. Michael Moore 21 Reputation points
    2022-06-14T15:16:34.977+00:00

    Thanks Carl. That did not work either. So, to recap everything and to make this a little easier on everyone. I have a database on my hard drive.
    The location of this database is on the desktop. The name of this database in PGA Matrix.accdb. Here is the exact location:
    C:\Users\Mikemoo\Desktop\PGA Matrix.accdb

    Within this database is a table called "Main Data"
    Upon exit of this database, I want to copy this table and ONLY this table to a network drive into another
    MS Access database called "PGA MATRIX 6-2022 Rep Version.accdb"

    The location of this database is here: Z:\CSC\MMOORE\ACCESS\Backup\

    So, can someone tell me how to write the DoCmd.TransferDatabase function to do this? I have tried about every combination I can think
    of and I am just in need of a sample and I'm good to go.

    Thank you in Advance!

    0 comments No comments

  2. Michael Moore 21 Reputation points
    2022-06-15T12:29:28.927+00:00

    Karl -

    That did the trick. Thank you so very much! I'm good!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.