carterlw12
Registered User.
- Local time
- Today, 09:49
- Joined
- Oct 2, 2018
- Messages
- 25
I am searched long and hard trying to find an answer to this and I have not.
- Importing .csv file via form button
- I do not want to edit the source file prior to importing
- Source file does not have headers
I have tried changing the code to include and not include headers and neither works. I get "F1 does not exist in destination table" or whatever the value of A1 in the source file does not exist in destination table.
I am self taught and about a month new to Access so just fyi when providing answers.
Here is my source code:
- Importing .csv file via form button
- I do not want to edit the source file prior to importing
- Source file does not have headers
I have tried changing the code to include and not include headers and neither works. I get "F1 does not exist in destination table" or whatever the value of A1 in the source file does not exist in destination table.
I am self taught and about a month new to Access so just fyi when providing answers.
Here is my source code:
Code:
Private Sub cmdImport_Click()
Dim FSO As New FileSystemObject
'On Error GoTo BadFormat
If Nz(Me.txtFilepath, "") = "" Then
MsgBox "No file has been selected. Please select a file."
Exit Sub
End If
If FSO.FileExists(Nz(Me.txtFilepath, "")) Then
DoCmd.TransferText acImportDelim, , "ADP_tbl", Me.txtFilepath, False
MsgBox "Import Successful!"
txtFilepath.Value = ""
Exit Sub
'BadFormat:
'MsgBox "The file you tried to import was not a .csv file."
End If
End Sub