Results 1 to 7 of 7
  1. #1
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    108

    DoCmd.Transferdatabase fails trying to link new table

    I have frontend .accdb and a backend .mdb. I want to add a new "Vehicle" and create an "orders" table in the backend, then link to the new table into the frontend. I use this code



    Code:
    wOrderVehicle = "tblOrdersGC33"
    DoCmd.CopyObject "N:\Database2012\MyBE.mdb", wOrderVehicle, acTable, "tblOrders"
    DoCmd.TransferDatabase acLink, "Microsoft Access", "N:\Database2012\MyBE.mdb", acTable, wOrderVehicle, wOrderVehicle, True
    The CopyObject works and a new table is created in the back end but the Transferdatabase line fails:

    Click image for larger version. 

Name:	Clipboard_03-10-2024_01.jpg 
Views:	27 
Size:	12.9 KB 
ID:	51580

    I have tried separating the two lines with a 2 second timer and tried to default the penultimate parameter as it seems superfluous, but always the same result

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you continuing to use mdb backend?
    Why are you programmatically creating new table? Is this a routine occurrence - why?

    I tested your code and it works without error for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    108
    I am using a backend because this app is about 20 years old and I am only maintaining and enhancing it as requirements change (Access 2016 at the moment)

    I have a "template" table in the backend tblOrders. All existing vehicles have an "orders" table - tblOrders(reg). Vehicles get replaced so I want to dynamically add a new tblorder(new reg).

    I have discovered that though apparently working the code #DoCmd.CopyObject "N:\Database2012\MyBE.mdb", wOrderVehicle, acTable, "tblOrders"# creates a linked table in the backend and it is linked ti itself?

    So I have tried variants of #DoCmd.TransferDatabase# using Import and Export.
    Import creates a table in the Front End and Export creates a linked table in the backend like CopyObject
    In all cases, attempting to link the backend table to the font end using TransferDatabase fails as before

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is not an optimal schema.

    Each vehicle should not have its own table. Should be one table with a field for vehicle code.

    Suggest you convert be to accdb sooner than later.

    Confused by your statement that CopyObject creates a linked table linked to itself. I do not understand this.

    Since I cannot replicate error, can't really help further.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    108
    Quote Originally Posted by June7 View Post
    This is not an optimal schema.
    I appreciate this but please enlighten me. This app has only two users. They download a copy of the accdb front end individually at start of day and access the same backend (.mdb) on a shared server. The mdb is the main business tables and the accdb is code and some temporary tables. The .accdb is stored on the same server where updated copies can be placed as changes are required. As the developer I upload changed versions of the accdb as required and the users can then reload the updated copy. This separates the changleable code from the (relatively) fixed data structure in the mdb.
    I only took on this task a few years ago, with limited experience of Access - this was how the system was set up back then - I have been too busy with a) learning Access and b) coping with a stream of change requests as the business evolves to look to deeply at the "architecture"

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    My second line in previous post expands on the first line.

    "Each vehicle should not have its own table. Should be one table with a field for vehicle code."

    Routinely modifying a database structure indicates bad design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    DB structure aside, I do not know why it is not working for you.

    This works for me.
    Code:
    Sub LinkTable()
    Dim wOrderVehicle As String, strDBBE As String
    wOrderVehicle = "tblOrdersGC33"
    strDBBE = "F:\Users\Paul\documents\Commissions_be.accdb"
    DoCmd.CopyObject strDBBE, wOrderVehicle, acTable, "tblTemp"
    DoCmd.TransferDatabase acLink, "Microsoft Access", strDBBE, acTable, wOrderVehicle, wOrderVehicle, True
    End Sub
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 20
    Last Post: 07-22-2021, 04:26 AM
  2. Replies: 1
    Last Post: 02-21-2018, 10:18 AM
  3. Menu doesn't open after TransferDatabase
    By ghillie30 in forum Access
    Replies: 6
    Last Post: 10-27-2011, 06:56 AM
  4. DoCmd.TransferDatabase acImport Issue
    By remingtont in forum Programming
    Replies: 0
    Last Post: 11-12-2010, 03:59 PM
  5. getting error using docmd.transferdatabase
    By haggisns in forum Import/Export Data
    Replies: 1
    Last Post: 11-02-2010, 08:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums