Skip to content

Commit a511a92

Browse files
committed
Added ImportAndDumpToAccessDB example
1 parent 9cc45b9 commit a511a92

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/examples/importation-examples.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Sub ImportRecords()
2020
Set CSVint = New CSVinterface
2121
Set conf = CSVint.ParseConfig
2222
With conf
23-
.path = "C:\100000.quoted.csv"
24-
.dynamicTyping = False
23+
.path = "C:\100000.quoted.csv"
24+
.dynamicTyping = False
2525
End With
2626
CSVint.GuessDelimiters conf 'Try to guess CSV file data delimiters
2727
CSVint.ImportFromCSV(conf).DumpToArray Arr 'Import and dump the data to an array
@@ -38,7 +38,7 @@ Sub TEST_DynamicTyping()
3838
Dim conf As parserConfig
3939
Dim CSVstring As String
4040
Dim Arr() As Variant
41-
41+
4242
Set CSVint = New CSVinterface
4343
Set conf = New parserConfig
4444
With conf
@@ -84,4 +84,33 @@ Sub ImportAndDumpToSheet()
8484
CSVint.ImportFromCSV(conf).DumpToSheet 'Import and dump the data to a new Worksheet
8585
Set CSVint = Nothing 'Terminate the current instance
8686
End Sub
87+
```
88+
89+
The \[EXAMPLE4\] shows how you can dump the imported data to an Access Database. The created table will have some indexed fields.
90+
91+
>⚠️**Caution**
92+
>{: .text-grey-lt-000 .bg-green-000 }
93+
>This method is only available in the [Access version of the CSVinterface.cls](https://github.com/ws-garcia/VBA-CSV-interface/raw/master/src/Access_version.zip) module.
94+
{: .text-grey-dk-300 .bg-yellow-000 }
95+
96+
#### [EXAMPLE4]
97+
```vb
98+
Sub ImportAndDumpToAccessDB()
99+
Dim path As String
100+
Dim conf As parserConfig
101+
Dim dBase As DAO.Database
102+
103+
Set CSVint = New CSVinterface
104+
Set conf = CSVint.ParseConfig
105+
With conf
106+
.path = "C:\100000.quoted.csv"
107+
.dynamicTyping = False
108+
End With
109+
CSVint.GuessDelimiters conf 'Try to guess CSV file data delimiters
110+
Set dBase = CurrentDb
111+
'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.
112+
CSVint.ImportFromCSV(conf).DumpToAccessTable dBase, "CSV_ImportedData", "Region", 2
113+
Set CSVint = Nothing
114+
Set dBase = Nothing
115+
End Sub
87116
```

0 commit comments

Comments
 (0)