Importing CSV and using CSV headings

thmsjlmnt3953

Registered User.
Local time
Today, 10:01
Joined
May 20, 2014
Messages
120
Hi,

I currently use the following to import a csv file into a staging table and then append and save the data to a table - however it doesnt use the headings from the csv file and creates an error table and a blank record where the headings should be apart from one column where it copies the name.

Would it be possible to use the headings as field names or just omit them completely and use the standard f1 f2 f3 etc access generates in the tmp table?

Code:
With Application.FileDialog(msoFileDialogFilePicker)

    .Title = "Select the CSV file to import"
    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "CSV Files", "*.csv", 1
    .Filters.Add "All Files", "*.*", 2
    If .Show = -1 Then
        strfilename = .SelectedItems(1)
        DoCmd.TransferText TransferType:=acImportDelim, _
            TableName:="tmpPicker_Stats", FileName:=strfilename
        Else
        Exit Sub
    End If
End With
 
one of the import options is a yes/no to use the first row of the csv as column headers.
 

Users who are viewing this thread

Back
Top Bottom