i have inherited an access tool that imports a file into its database, makes a series of changes, then in its final stages exports the file back into the folder it originally came from with changes. this all works fine.
however, what i want it to do, is export the file, but rename it to reflect parent folder.
For example, V:HQ\red\yellow\blue\0000.txt
what i want is for the file to be named blue in this instance (will change, path is variable so cannot hard code it).</SPAN>
What i have so far:</SPAN>
Dim sL2ImportFileName As String, sNewName As String, sL2FilePath As String
Dim iStartPos As Integer, iSlashPos As Integer
sL2FilePath = DLookup("FilePath", "[tbl L2 Import Details]", "[File Type] = 'L2D'")</SPAN>
iPos = Len(sL2FilePath)
While Mid(sL2FilePath, iPos, 1) <> "\"
iPos = iPos - 1
Wend
If Dir(sL2FilePath & "l2.xls") <> "" Then Kill sL2FilePath & ".l2.xls"
sNewName = Left(sL2FilePath, iPos) & "l2d.txt"
DoCmd.TransferText acExportDelim, "xls export", "colour", sNewName, True
Name sNewName As sL2FilePath & "l2.xls" </SPAN>
As i say currently this is exporting the file named 0000. that works fine. What I want, is for the file to take the name of the parent folder the file is contained in. </SPAN></SPAN>
The File path is contained in the Access table referenced in the D look up. It uses this reference to find the location where it needs to write back to. </SPAN></SPAN>
I am using Excel and Access 2003</SPAN></SPAN>
however, what i want it to do, is export the file, but rename it to reflect parent folder.
For example, V:HQ\red\yellow\blue\0000.txt
what i want is for the file to be named blue in this instance (will change, path is variable so cannot hard code it).</SPAN>
What i have so far:</SPAN>
Dim sL2ImportFileName As String, sNewName As String, sL2FilePath As String
Dim iStartPos As Integer, iSlashPos As Integer
sL2FilePath = DLookup("FilePath", "[tbl L2 Import Details]", "[File Type] = 'L2D'")</SPAN>
iPos = Len(sL2FilePath)
While Mid(sL2FilePath, iPos, 1) <> "\"
iPos = iPos - 1
Wend
If Dir(sL2FilePath & "l2.xls") <> "" Then Kill sL2FilePath & ".l2.xls"
sNewName = Left(sL2FilePath, iPos) & "l2d.txt"
DoCmd.TransferText acExportDelim, "xls export", "colour", sNewName, True
Name sNewName As sL2FilePath & "l2.xls" </SPAN>
As i say currently this is exporting the file named 0000. that works fine. What I want, is for the file to take the name of the parent folder the file is contained in. </SPAN></SPAN>
The File path is contained in the Access table referenced in the D look up. It uses this reference to find the location where it needs to write back to. </SPAN></SPAN>
I am using Excel and Access 2003</SPAN></SPAN>