Export Data from one ms access database to another database

ria.arora

Registered User.
Local time
Today, 21:56
Joined
Jan 25, 2012
Messages
109
Hi

I have one front end application which in MS access and few backend databases (MS Access). I'm able to export the whole table from one database to another database using below code. But my issue is I want export only selected columns only and based on condition (e.g. Date > so and so).

Code:
Private Sub ImportFromAccess(sDatabaseID As String, sSourceTradeBookTbl As String, sDestTradeBookTbl As String)
    Dim objApp As Object
    Dim strPnPDatabaseName As String
    Dim strPnPDatabasePassword As String
    Dim strSourceDatabasePathNName As String 'Source Database Path and Name, from where data need to imported
    Dim strDestDatabasePathNName As String 'Destination Database Path and Name, where data need to exported
    strSourceDatabasePathNName = ExtractDatabaseDetails.GetDatabasePath(sDatabaseID) & "\" & ExtractDatabaseDetails.GetDatabaseName(sDatabaseID)
    strDestDatabasePathNName = ExtractDatabaseDetails.GetDatabasePath(gsPnPDatabaseID) & "\" & ExtractDatabaseDetails.GetDatabaseName(gsPnPDatabaseID)
'    strPnPDatabasePassword = GetDatabasePassword(gsPnPDatabaseID)
    Set objApp = New Access.Application
    
    'Open current database to export the table from this opened database to destination database
    objApp.OpenCurrentDatabase strSourceDatabasePathNName, False
    
    'Export the needed tables and queries
    'Parameters
    'strNNADatabasePathNName - Source Database name with full path
    'strNNASourceTableName - Table Name from Source Database
    'strNNADestTableName - Table Name from Destination Database
    'False - You're importing all the data as well, True would just import the structure
    objApp.DoCmd.TransferDatabase Access.AcDataTransferType.acExport, _
                                        "Microsoft Access", _
                                        strDestDatabasePathNName, _
                                        Access.AcObjectType.acTable, "NNA data", "tbl_NNA"
End Sub

My source and destination both databases are password protected (currently I have removed the password for testing).

I don't want to use LOOP means SELECT data from the source database and use loop and insert one by one record in target database cause there are 150K records and this will be very slow. Is there better solution to use SELECT ColA, ColB, ColJ, ColP FROM XXXXTable (Source Database password protected) and INSERT INTO Destination Database (Password Protected). If possible I can use TransferDatabase method but I'm not able to figure out how to export only selected columns

I don't want to use link table as well.

Is there anyway to disable the access application as I'm using OpenCurrentDatabase so it's flashing up the database. I know if disable the security warning manually once in access then it will not make the application "visible" but this need to be distributed to users and I can't disable this in each PC.

Please help. Thanks in advance.
 

Users who are viewing this thread

Back
Top Bottom