Results 1 to 8 of 8
  1. #1
    Harley Guy is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    57

    Move or Copy a table to another database

    First off, let me say thanks to everyone in this forum...you folks have helped me out a lot!

    I am doing server audits for my company and I need to archive each audit that gets completed.



    I have code written to copy the current audit table to another name in the same database but I would like to be able to copy it to another database while still being able to rename.

    Here is the coding I have so far:

    Public Function CopyTable_Click()
    On Error GoTo Err_ErrorHandler
    DoCmd.CopyObject , InputBox("Please Enter New Table Name"), acTable, "Server List"
    MsgBox "Table successfully copied.", vbInformation
    Exit_ErrorHandler:
    strTable = vbNullString
    Exit Function
    Err_ErrorHandler:
    MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
    Resume Exit_ErrorHandler
    End Function

    If it's at all possible, where would I put the server path of the renamed object?

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It is the first parameter of the CopyObject command and you are currently skipping it:
    expression.CopyObject(DestinationDatabase, NewName, SourceObjectType, SourceObjectName)

  3. #3
    Harley Guy is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    57
    So I would place the new parameter in this section?

    DoCmd.CopyObject , InputBox("Please Enter New Table Name"), acTable, "Server List"
    to
    DoCmd.expressionCopyObject(server path where destination database resides , InputBox("Please Enter New Table Name"), acTable, "Server List"

    When I do that, I get a compile error starting at the path of server
    (\\Itdrenm406\operational_services\Data Center Operations\ECC Server Audit & Inventory\Test DB's.Archived Audit Results.mdb)

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Dim ServerPath As String
    ServerPath = "\\Itdrenm406\operational_services\Data Center Operations\ECC Server Audit & Inventory\Test DB's.Archived Audit Results.mdb"
    DoCmd.CopyObject ServerPath, InputBox("Please Enter New Table Name"), acTable, "Server List"

  5. #5
    Harley Guy is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    57
    That did the trick! Thank you sir!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That's great! Are you ready to follow the link in my sig and mark this thread as Solved?

  7. #7
    Harley Guy is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    57
    Marked Solved...Thanks!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad to help. Another satisfied Forum member added to the list.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-12-2010, 08:38 AM
  2. Copy one table to another database
    By ashthebear in forum Access
    Replies: 2
    Last Post: 06-15-2010, 08:46 AM
  3. Move data from one table to another
    By rebyrd in forum Queries
    Replies: 2
    Last Post: 12-24-2009, 12:52 AM
  4. How to move copy queries and reports.
    By Fred C in forum Access
    Replies: 1
    Last Post: 11-08-2008, 10:24 AM
  5. Making a backup copy of table or database
    By wasim_sono in forum Access
    Replies: 0
    Last Post: 03-09-2006, 05:44 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