feelinfroggy
New member
- Local time
- Yesterday, 23:26
- Joined
- Dec 5, 2002
- Messages
- 8
Help! I have an unbound listbox on a form that has its rowsource set by code on form load, current, and activate events. It is populated with the contents of a directory on a network drive. The exact location is determined by the code below which determines the folder name by concatenating two fields together. It works great except that it only displays the first file it finds in the folder and not the entire contents of the folder. It also truncates the file name that it displays in the listbox but only by one letter. What am I doing wrong?
Code:
Dim strLeadName As String, strLeadNum As String, strPath As String
strLeadName = Replace(Me.CompanyName, " ", "")
strLeadName = Left(strLeadName, 5)
strLeadNum = Right(Me.LeadNumber, 5)
strFolder = strLeadName & "_" & strLeadNum & "\"
'Debug.Print strFolder
strPath = "N:\AAA_Leads_Working\" & strFolder
strPath = Trim(strPath)
strFile = Dir(strPath & "*.*")
strRowSource = strRowSource & strFile
Do Until strFile = ""
strFile = Dir
Loop
If strRowSource <> "" Then
Me.lstDir.RowSource = Left(strRowSource, Len(strRowSource) - 1)
End If
Code:
Dim strLeadName As String, strLeadNum As String, strPath As String
strLeadName = Replace(Me.CompanyName, " ", "")
strLeadName = Left(strLeadName, 5)
strLeadNum = Right(Me.LeadNumber, 5)
strFolder = strLeadName & "_" & strLeadNum & "\"
'Debug.Print strFolder
strPath = "N:\AAA_Leads_Working\" & strFolder
strPath = Trim(strPath)
strFile = Dir(strPath & "*.*")
strRowSource = strRowSource & strFile
Do Until strFile = ""
strFile = Dir
Loop
If strRowSource <> "" Then
Me.lstDir.RowSource = Left(strRowSource, Len(strRowSource) - 1)
End If