VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS )

by vinay nataraj (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 29th October 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS )

API Declarations


Dim AccesApp As Access.Application
Dim Newdatabasepath As String
Dim fso As FileSystemObject

Rate Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS )



Public Sub ExportTable(ByVal strCurrentdatabasepath As String, ByVal strNewDatabasePath As String, ByVal strSourceTableName As String, ByVal strDestinationTableName As String)
On Error GoTo errcheck:
'***********************************************************************************************************************************************************************************
    Set fso = New FileSystemObject
    If fso.FileExists(strCurrentdatabasepath) = False Then
        MsgBox "Invalid Current DataBase"
        Exit Sub
    ElseIf fso.FileExists(strNewDatabasePath) = False Then
        MsgBox "Invalid Destination Database"
        Exit Sub
    ElseIf strDestinationTableName = "" Or strDestinationTableName = " " Then
        MsgBox "Please Eneter Destination TableName "
        Exit Sub
    ElseIf strSourceTableName = "" Or strSourceTableName = " " Then
        MsgBox "Please Eneter Source TableName "
        Exit Sub
    End If
    Set AccesApp = New Access.Application
    Newdatabasepath = strNewDatabasePath
'Open and set the path for the current database
    AccesApp.OpenCurrentDatabase strCurrentdatabasepath
'Export the Source table from current database to The Destination table in the back-up / new  database
    AccesApp.DoCmd.TransferDatabase acExport, "Microsoft Access", Newdatabasepath, acTable, strSourceTableName, strDestinationTableName
    MsgBox "Table Successfully Exported"
'***********************************************************************************************************************************************************************************
    AccesApp.CloseCurrentDatabase
    AccesApp.Quit
    Set AccesApp = Nothing
    Set fso = Nothing
'***********************************************************************************************************************************************************************************
Exit Sub
errcheck:
    MsgBox Err.Description
End Sub

Download this snippet    Add to My Saved Code

Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS ) Comments

No comments have been posted about Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS ). Why not be the first to post a comment about Export Source Table from Current Database To The Destination Table In New Database ( IN ACCESS ).

Post your comment

Subject:
Message:
0/1000 characters