Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
Import mutiple name text files into Access 2003
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Douglas J Steele, post: 14146798"] Public Sub pfImport() On Error GoTo Err_F Dim db As DAO.Database Dim strPathFile As String, strFile As String, strPath As String, strSpec As String Dim strTable As String, ynFieldName As Boolean Set db = CurrentDb ynFieldName = False strPath = "C:\TextFiles\" 'where my files are located strTable = "NotepadTable" 'the name of my Access table strFile = Dir(strPath & "*.txt") Do While Len(strFile) > 0 strPathFile = strPath & strFile DoCmd.TransferText acImportDelim, strSpec, strTable, strPathFile, ynFieldName db.Execute "UPDATE NotepadTable SET FileName = '" & strFile & "' " _ "WHERE FileName Is Null", dbFailOnError ' Uncomment out the next code step if you want to delete the 'file after it's imported ' Kill strPathFile strFile = Dir() Loop Cleanup: Set db = Nothing Exit Sub Exit_F: Resume Cleanup Exit Sub wrote in message I am importing succesfully multiple text files into Access 2003, however I need to ad a column in my access table to contain the name of each file in order for me to identify each record set, any help would be greatly appreciated, I am using the folowing VB Public Sub pfImport() On Error GoTo Err_F Dim strPathFile As String, strFile As String, strPath As String, strSpec As String Dim strTable As String, ynFieldName As Boolean ynFieldName = False strPath = "C:\TextFiles\" 'where my files are located strTable = "NotepadTable" 'the name of my Access table strFile = Dir(strPath & "*.txt") Do While Len(strFile) > 0 strPathFile = strPath & strFile DoCmd.TransferText acImportDelim, strSpec, strTable, strPathFile, ynFieldName ' Uncomment out the next code step if you want to delete the 'file after it's imported ' Kill strPathFile strFile = Dir() Loop Exit_F: Exit Sub [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
Import mutiple name text files into Access 2003
Top