I am going through a directory and grabbing the folder names 4 deep and then grabbing the filename. I am having problems when it goes back up the go to the next folder I am getting an error message "Invalid procedure call or argument". I think it is because I have already called the Dir.

Thanks
Shannon

VB Code:
  1. Private Function GetClient(iPath As String) As String
  2.  
  3.     Dim MyDir
  4.     Dim MyClient As String
  5.     MyClient = Dir(iPath, vbDirectory)
  6.    
  7.     Do While MyClient <> ""
  8.         If MyClient <> "." And MyClient <> ".." Then
  9.             If (GetAttr(iPath & MyClient) And vbDirectory) = vbDirectory Then
  10.                 Debug.Print MyClient
  11.                 Call GetCategory(iPath & MyClient & "\")
  12.                
  13.             End If
  14.         End If
  15.         MyClient = Dir
  16.     Loop
  17.        
  18.    
  19. End Function
  20.  
  21. Private Sub Form_Activate()
  22.    
  23.     Call GetClient("\\192.168.75.120\staging\")
  24.    
  25. End Sub
  26.  
  27. Private Function GetCategory(MyClient As String) As String
  28.    
  29.     Dim MyDir1
  30.     Dim MyCategory As String
  31.     MyCategory = Dir(MyClient, vbDirectory)
  32.    
  33.     Do While MyCategory <> ""
  34.         If MyCategory <> "." And MyCategory <> ".." Then
  35.             If (GetAttr(MyClient & MyCategory) And vbDirectory) = vbDirectory Then
  36.                 Debug.Print MyClient & MyCategory
  37.                 Call GetSource(MyClient & MyCategory & "\")
  38.             End If
  39.         End If
  40.         MyCategory = Dir
  41.     Loop
  42.    
  43. End Function
  44.  
  45. Private Function GetSource(MyCategory As String) As String
  46.    
  47.     Dim MyDir2
  48.     Dim MySource As String
  49.     MySource = Dir(MyCategory, vbDirectory)
  50.    
  51.     Do While MySource <> ""
  52.         If MySource <> "." And MySource <> ".." Then
  53.             If (GetAttr(MyCategory & MySource) And vbDirectory) = vbDirectory Then
  54.                 Debug.Print MyCategory & MySource
  55.                 Call GetGUID(MyCategory & MySource & "\HOLDING\")
  56.             End If
  57.         End If
  58.         MySource = Dir  <-- I am getting the error here after calling GetGUID
  59.     Loop
  60.    
  61. End Function
  62.  
  63. Private Function GetGUID(MySource As String) As String
  64.    
  65.     Dim MyDir3
  66.     Dim MyGUID As String
  67.     MyGUID = Dir(MySource, vbDirectory)
  68.    
  69.     Do While MyGUID <> ""
  70.         If MyGUID <> "." And MyGUID <> ".." Then
  71.             Debug.Print MyGUID
  72.         End If
  73.         MyGUID = Dir
  74.     Loop
  75.    
  76. End Function