Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Get the Name of Last File

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I'm trying to get the name of the last file in a specified directory. The code that I have so far will get name of the first file. What do I need to change to get the last one?
Tanks for the help, Kopy

Here's my code :
===========================================================

Dim fname, fnamefull As String
Dim I As Variant

Set fs = CreateObject("Scripting.FileSystemObject")
Set fl = fs.GetFolder("C:\Consulting\PSoft")

For Each f In fl.Files
I = I + 1
fname = f.Name
fnamefull = fl & "\" & fname
DoCmd.TransferText acImportDelim, "", "BBP_DB", fnamefull, True, ""
If I = 1 Then
Exit Function
End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top