G
Guest
Can someone help with the following error? I am trying to import a .csv file
into a table.
This is what I have thus far
A form with 3 buttons and a text box
1. when you click on the first button you will have the option to browse for
the file --- This works fine.
2. Once you click on the second button it will import the file – The
following is the code I have. And the error I am getting when I click this
button is
---------------------------
Microsoft Access
---------------------------
Error 2465 - Microsoft Access can't find the field '|' referred to in your
expression.
---------------------------
OK
---------------------------
Private Sub cmdImport_Click()
On Error GoTo ErrorCheck
varFilename = Me.txtInputFile
If IsNull(varFilename) Then
MsgBox "You must enter an input filename.", vbExclamation, " "
Me.txtInputFile.SetFocus
Exit Sub
End If
DoCmd.RunSQL "delete [InfoPointBehavioralScores(old)].* from
[InfoPointBehavioralScores(old)];"
DoCmd.RunSQL "INSERT INTO [InfoPointBehavioralScores(old)]SELECT
[InfoPointBehavioralScores].*FROM [InfoPointBehavioralScores];"
DoCmd.RunSQL "DELETE [InfoPointBehavioralScores].* FROM
[InfoPointBehavioralScores];"
DoCmd.Transfertext acImport, [InfoPoint Behavioral Scores v1],
InfoPointBehavioralScores, varFilename, ture
Exit Sub
ErrorCheck:
Select Case Err.Number
Case 7874 'Import file not there to delete
Resume Next
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description
Exit Sub
End Select
End Sub
Thank You in advance for you help
into a table.
This is what I have thus far
A form with 3 buttons and a text box
1. when you click on the first button you will have the option to browse for
the file --- This works fine.
2. Once you click on the second button it will import the file – The
following is the code I have. And the error I am getting when I click this
button is
---------------------------
Microsoft Access
---------------------------
Error 2465 - Microsoft Access can't find the field '|' referred to in your
expression.
---------------------------
OK
---------------------------
Private Sub cmdImport_Click()
On Error GoTo ErrorCheck
varFilename = Me.txtInputFile
If IsNull(varFilename) Then
MsgBox "You must enter an input filename.", vbExclamation, " "
Me.txtInputFile.SetFocus
Exit Sub
End If
DoCmd.RunSQL "delete [InfoPointBehavioralScores(old)].* from
[InfoPointBehavioralScores(old)];"
DoCmd.RunSQL "INSERT INTO [InfoPointBehavioralScores(old)]SELECT
[InfoPointBehavioralScores].*FROM [InfoPointBehavioralScores];"
DoCmd.RunSQL "DELETE [InfoPointBehavioralScores].* FROM
[InfoPointBehavioralScores];"
DoCmd.Transfertext acImport, [InfoPoint Behavioral Scores v1],
InfoPointBehavioralScores, varFilename, ture
Exit Sub
ErrorCheck:
Select Case Err.Number
Case 7874 'Import file not there to delete
Resume Next
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description
Exit Sub
End Select
End Sub
Thank You in advance for you help