illusionek
Registered User.
- Local time
- , 19:25
- Joined
- Dec 31, 2013
- Messages
- 92
I use a simple code (below) to import text files from a folder. All works well but now I need to populate a value from particular record for all records from this file.
I have attached an example of my table after importing all text files.
I need to add another column and based on this example I would like to see PO000072 in Field9 for the first 21 rows then PO000073 for another 21 rows and PO000074 for others. Number of rows will vary depending on the file.
I know I will need to use a stagging table for this, I just do not know how to point Access to PO000072 etc. The whole line can be easily identified because it will always start with DH at the beginning.
Can anyone help?
I have attached an example of my table after importing all text files.
I need to add another column and based on this example I would like to see PO000072 in Field9 for the first 21 rows then PO000073 for another 21 rows and PO000074 for others. Number of rows will vary depending on the file.
I know I will need to use a stagging table for this, I just do not know how to point Access to PO000072 etc. The whole line can be easily identified because it will always start with DH at the beginning.
Can anyone help?
Code:
Function ImportText()
Dim strFile As String
' Set file directory for files to be imported
strPath = "C:\Documents\"
' Tell it to import all Excel files from the file directory
strFile = Dir(strPath & "*.txt*")
' Start loop
Do While strFile <> ""
' Import file
DoCmd.TransferText acImportDelim, , "Table1", strPath & strFile, False
' Loop to next file in directory
strFile = Dir
Loop
End Function