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