Skip to main content Link Search Menu Expand Document (external link) Copy Copied

DumpToAccessTable

Dumps the data from the current instance to a Microsoft Access Database (.accdb).


⚠️Caution

This method is only available in the Access version of the CSVinterface.cls module.

Syntax

expression.DumpToAccessTable(dBase, tableName, [fieldsToIndexing])

Parameters

Part Description
dBase Required. Identifier specifying a DAO.Database object variable representing the output database.
tableName Required. Identifier specifying a String Type variable representing the output database table name.
fieldsToIndexing Optional. Identifiers specifying a Variant Type variables representing the fields of the table in where indexing is required.

Returns value

None

📝Note

Before dump data, is required to make a call to the ImportFromCSV or ImportFromCSVstring method.

See also
ImportFromCSV method, ImportFromCSVstring method.

Behavior

If a table named tablename already exists in the database, the method will attempt to append the data. User can specify the fields for create indexes by name or by absolute position through the fieldsToIndexing parameter. When the fieldsToIndexing parameter is not set, the data is dumped into the database table without indexing more fields than the record position.

⚠️Caution

All the data is dumped as “Short Text”. If the CSV file has some of the special chars listed in this article an error can occur.

☕Example

Sub ImportAndDumpToAccessDB()
    Dim CSVint As CSVinterface
    Dim path As String
    Dim dBase As DAO.Database
    
    Set CSVint = New CSVinterface
    With CSVint
        .parseConfig.path = Environ("USERPROFILE") & "\Desktop\Demo_100000records.csv"
        Set .parseConfig.dialect = .SniffDelimiters(.parseConfig) 'Try to guess CSV file data delimiters
        Set dBase = CurrentDb
        'Import and dump the data into a new database table. This will create indexes for the "Region" field and for the second field in the table.
        .ImportFromCSV(.parseConfig).DumpToAccessTable dBase, "CSV_ImportedData", "Region", 2
    End With
    Set CSVint = Nothing
    Set dBase = Nothing
End Sub

Back to Methods overview