Results 1 to 4 of 4
  1. #1
    rameshmeena is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Location
    Riyadh
    Posts
    16

    How can i transfer a selected Table from Access data base using vba

    Dear sir,

    Kindly inform me how to transfer selected table ( not all tables) from access data base using VBA. At present i am using the following VBA but it is copying all Tables.




    Sub BackUp()
    'Make the folder a trusted location
    Dim sFile As String, oDB As DAO.Database 'Set reference to MS Data Access objects lib.
    'If DAO.dll does not load, then find ACEDAO.dll
    'in program files ( 64-bit machine) or MS office AC DB Engine object
    sFile = CurrentProject.Path & "" & Format(Date, "dd-mm-yyyy") & ".accdb"
    'If Dir(sFile) <> "'" Then Kill sFile
    Set oDB = DBEngine.Workspaces(0).CreateDatabase(sFile, dbLangGeneral)
    oDB.close
    Dim oTD As TableDef
    For Each oTD In CurrentDb.TableDefs
    If Left(oTD.Name, 4) <> "Msys" Then
    'DoCmd.CopyObject sFile, , acTable, oTD.Name



    End If
    Next oTD




    DoCmd.CopyObject sFile, , acTable, oTD.tbl1employees


    MsgBox " Backup of tables is stored in teh same folder " & vbCr & _
    " under the file name " & Right(sFile, Len(sFile) - InStrRev(sFile, ""))



    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you dont need vb.
    create a query of the data you need.
    put the transfer commands in a macro. (either sendobject, or transferspreadsheet)
    run the macro.

  3. #3
    rameshmeena is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Location
    Riyadh
    Posts
    16
    Quote Originally Posted by ranman256 View Post
    you dont need vb.
    create a query of the data you need.
    put the transfer commands in a macro. (either sendobject, or transferspreadsheet)
    run the macro.
    Dear Sir,

    thank you very much, i am a beginner , not a professional in Access, the vba which is write above is copied from one of the you tube presentations.

    so can you please give me with examples how to do the query and put transfer commands
    Attached Files Attached Files

  4. #4
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    you can link just one table not a whole DB. If that's possible then its a better option.

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

Similar Threads

  1. Replies: 4
    Last Post: 09-18-2014, 06:41 AM
  2. access data base help
    By janu1234 in forum Access
    Replies: 2
    Last Post: 04-19-2012, 01:30 AM
  3. Replies: 2
    Last Post: 11-02-2011, 08:31 AM
  4. Transfer data from ListView to Table
    By Zyckie in forum Access
    Replies: 1
    Last Post: 12-15-2009, 11:23 AM
  5. Replies: 3
    Last Post: 04-23-2006, 09:09 PM

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