Hi,
You helped me a lot setting up the following code:
Code:
Private Sub btnImport_Click()
Dim fDialog As FileDialog
Dim strFileName As String
Dim db As DAO.Database
Dim sqlStr As String
Dim varFile As Variant
Me.FileList.RowSource = ""
On Error GoTo errHandler
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Set db = CurrentDb
With fDialog
.AllowMultiSelect = True
.Title = "Please select one or more files"
.Filters.Clear
.Filters.Add "Excel Spreadsheets", "*.xls, *.xlsx, *.xlsm, *.xlsb"
If .Show = True Then
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
strFileName = varFile
sqlStr = "INSERT INTO tblTransaction (YearMo, Entity, Acct, ActDKK, FcDKK, ActLocCur, FcLocCur, Comment) " & _
"SELECT * FROM (SELECT YearMo, Entity, Acct, ActDKK, FcDKK, ActLocCur, FcLocCur, Replace([Comment1],Chr(10),Chr(13) & Chr(10)) " & _
"As Comment FROM [DB$] AS xlData IN '" & strFileName & "'[Excel 12.0;HDR=yes;IMEX=2;ACCDB=Yes])"
db.Execute sqlStr
MsgBox strFileName & vbCrLf & db.RecordsAffected & " records imported"
Next
Else
MsgBox "Import selection was cancelled."
Exit Sub
End If
End With
exitHere:
Set fDialog = Nothing
Set db = Nothing
Exit Sub
During the testing I didn't consider triggering length limits (apparently 255 characters seem to be an issue as on more than one occasion the reference is http://allenbrowne.com/ser-63.html, which I've been reading through).
I'm still having problems understanding why the import of below Excel example...

...results in being truncated as below.

The issues described in above link (aggregation, uniqueness, format property, union query, concatenated fields, row source) do, as far as I see it, not apply to my coding.
I also tried a few shots in the dark based on recommendation for other users facing this issue (e.g., put the memo field in the front in the related statements), however this did not help resolving the issue.
So obviously the question is: How can I make sure, that the whole content of the affected field can be imported into Access?