M
mhmaid
I have found this code in this group , with thanks to the the one who created
it .but dont know how can i use it
Function fImportAllFiles()
Dim strfile As String
Dim strPath As String
'File path '
strPath = "YOUR FILE PATH HERE"
'Change the default directory to the file path
'
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, , "TableName", strPath & "\" &
strfile
'delete the file (consider moving it to an Archive folder instead.)
'Kill strPath & "/" & strfile
'Call Dir to get the next file
'
strfile = Dir
Loop
End Function
I Have changed it to the following
Function fImportAllFiles()
Dim strfile As String
Dim strPath As String
'File path '
strPath = "C:\txtfiles"
'Change the default directory to the file path
'
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, , "Patients", strPath & "\" &
strfile
'delete the file (consider moving it to an Archive folder instead.)
'Kill strPath & "/" & strfile
'Call Dir to get the next file
'
strfile = Dir
Loop
End Function
my files are stored in c:\txtfiles
i want to import them to the access table called patients
need urgent help
all files are xls sheets in the type txt ( tab delimited)
tried but failed
I am not able to import the files manually as I am getting the following
errer msg:
the wizard was unable to import the file.please make sure it exist and in
the correct format
thanks
it .but dont know how can i use it
Function fImportAllFiles()
Dim strfile As String
Dim strPath As String
'File path '
strPath = "YOUR FILE PATH HERE"
'Change the default directory to the file path
'
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, , "TableName", strPath & "\" &
strfile
'delete the file (consider moving it to an Archive folder instead.)
'Kill strPath & "/" & strfile
'Call Dir to get the next file
'
strfile = Dir
Loop
End Function
I Have changed it to the following
Function fImportAllFiles()
Dim strfile As String
Dim strPath As String
'File path '
strPath = "C:\txtfiles"
'Change the default directory to the file path
'
ChDir strPath
'Find the firsttext file
'
strfile = Dir("*.txt")
'Loop through the string & import the files
'
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, , "Patients", strPath & "\" &
strfile
'delete the file (consider moving it to an Archive folder instead.)
'Kill strPath & "/" & strfile
'Call Dir to get the next file
'
strfile = Dir
Loop
End Function
my files are stored in c:\txtfiles
i want to import them to the access table called patients
need urgent help
all files are xls sheets in the type txt ( tab delimited)
tried but failed
I am not able to import the files manually as I am getting the following
errer msg:
the wizard was unable to import the file.please make sure it exist and in
the correct format
thanks