Private Sub IMPORT_tbl_Click()
Dim strPath As String
Dim strFile As String
Dim strTable As String
Dim strSpecification As String
Dim intImportType As AcTextTransferType
Dim blnHasFieldNames As Boolean
'DELETE THE SELECTED STRIPES TABLES BEFORE IMPORTING
'DoCmd.DeleteObject acTable, "Cust"
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from cust", False
DoCmd.SetWarnings True
Delete_Table ("cust_tmp")
' Let user select a folder
With Application.FileDialog(4)
If .Show Then
strPath = .SelectedItems(1)
Else
MsgBox "You didn't select a folder", vbExclamation
Exit Sub
End If
End With
If Right(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
'DoCmd.OpenForm "frmMessage"
'Forms!frmMessage.Repaint
' Loop through the text files in the folder and if saved as decsribed then import them
'
strFile = Dir(strPath & "*.TXT")
Do While strFile <> ""
'IMPORT MARD
If strFile = "cust.TXT" Then
strTable = "cust_tmp"
strSpecification = "cust"
blnHasFieldNames = False
intImportType = acLinkDelim
Else
strTable = ""
End If
' Import text file as pre described
If strTable <> "" Then
DoCmd.TransferText _
TransferType:=intImportType, _
SpecificationName:=strSpecification, _
TableName:=strTable, _
FileName:=strPath & strFile, _
HasFieldNames:=blnHasFieldNames
End If
strFile = Dir()
Loop
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO cust SELECT * FROM cust_tmp", False
Delete_Table ("cust_tmp")
DoCmd.SetWarnings True
End Sub