Question : Import .csv file into Access

Hello,
I have a Access 2002-2003 application that will import a .csv file into a table used to store phone numbers. This works fine.
I wanted to make a different application that also had a phone list and I wanted to use these same forms, tables, modules, references, etc. I started a new blank database, imported everything necessary, set the references (with the exception of Microsoft Outlook 11.0 Object Library which wasn't needed in the new application).
The new application won't correctly import the same .csv file that the old application would, I get the error
Error No:3625; Description: The text file specification 'PhoneList Import Specification' does not exist. You cannot import, export, or link using the specification.
What is an "Import Specification"?
Thanks in advance for any help
My code for the import is as follows:
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
Private Sub Command16_Click()
On Error GoTo ErrorHandler
Dim dlgOpen As Office.FileDialog
Dim InitialFileName As String
Dim SelectFile As String
Dim strFileNameAndPath As String
Dim varSelectedItem As Variant
Dim MyPath As String
 
Set dlgOpen = Application.FileDialog(msoFileDialogFilePicker)
With dlgOpen
    .Title = "Select a phone list"
    .AllowMultiSelect = False
    .Filters.Add "CSV Files Only", "*.csv", 1
    .InitialFileName = "C:\"
    .InitialView = msoFileDialogViewDetails
    
   If .Show = -1 Then strFileNameAndPath = .SelectedItems(1)
         
   End With
  
  Me.txtFPath = strFileNameAndPath
  MyPath = Me.txtFPath
    DoCmd.SetWarnings False
    DoCmd.TransferText acImportDelim, "PhoneList Import Specification", "tblPhtemp", MyPath
    
    MsgBox ("Finished importing Phone List")
   
   DoCmd.SetWarnings True
  Me.Form.Requery
 
ErrorHandlerExit:
Set dlgOpen = Nothing
Exit Sub
 
ErrorHandler:
  If Err.Number = 2522 Then
   Exit Sub
    End If
  
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
   Resume ErrorHandlerExit
 
End Sub

Answer : Import .csv file into Access

you will use the same import process when you imported the other objects
file> get external data > import

click on the Options button
select import/export specs from the Import groups
Random Solutions  
 
programming4us programming4us