Solved Multiple search engine with dropdowns

I use onedrive but yes I thought that might be the only way I'll check my onedrive as haven't run that code in years that is if i can even find it lol
 
I have managed to remove the hidden and system folders from showing up, but I don't know where it is to do the same with the counts.

Code:
Private Sub SpanFolders(SourceFolderFullName As String, Optional ParentID As Long = 0, Optional ByVal FolderLevel = 0)

' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
    'Dim FSO As Object 'Scripting.FileSystemObject
    Dim SourceFolder As Scripting.Folder 'Scripting.Folder
    Dim SubFolder As Scripting.Folder 'Scripting.Folder
    Dim FileItem As Scripting.file 'Scripting.File
   ' Dim ParentID As Long

    
    Set SourceFolder = FSO.GetFolder(SourceFolderFullName)
    
    FolderLevel = FolderLevel + 1
    LogFilesFolders SourceFolder.Name, SourceFolder.Path, SourceFolder.Type, ParentID, fft_Folder, FolderLevel
    ParentID = GetFolderID(SourceFolder.Path)
    For Each FileItem In SourceFolder.Files
        If (FileItem.Attributes And 2) <> 2 And (FileItem.Attributes And 4) <> 4 Then
            LogFilesFolders FileItem.Name, FileItem.Path, FileItem.Type, ParentID, fft_File, FolderLevel
        End If
    Next FileItem
    
    For Each SubFolder In SourceFolder.SubFolders
        ParentID = GetFolderID(SourceFolder.Path) ' The record has just been added so get PK by name
    '   LogFilesFolders SubFolder.Name, SubFolder.Path, SubFolder.Type, ParentID, fft_Folder, FolderLevel
       If (SubFolder.Attributes And 2) <> 2 And (SubFolder.Attributes And 4) <> 4 Then
            SpanFolders SubFolder.Path, ParentID, FolderLevel
       End If
    Next SubFolder

    Set FileItem = Nothing
    Set SourceFolder = Nothing

End Sub

Private Sub SpanFolderSummations(SourceFolderFullName As String, Optional ParentID As Long = 0, Optional ByVal FolderLevel = 0, Optional CountHiddenSystem As Boolean = False)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
    'Dim FSO As Object 'Scripting.FileSystemObject
    Dim SourceFolder As Scripting.Folder 'Scripting.Folder
    Dim SubFolder As Scripting.Folder 'Scripting.Folder
    Dim FileItem As Scripting.file 'Scripting.File
    
    Dim FolderCount As Long
    Dim FileCount As Long
     
    FolderLevel = FolderLevel + 1
    Set SourceFolder = FSO.GetFolder(SourceFolderFullName)
    FolderCount = SourceFolder.SubFolders.Count
    If CountHiddenSystem Then
         FileCount = SubFolder.Files.Count   'This will count hidden as well
       Else
        FileCount = 0
        For Each FileItem In SourceFolder.Files
           If (FileItem.Attributes And 2) <> 2 And (FileItem.Attributes And 4) <> 4 Then
             FileCount = FileCount + 1
           End If
        Next FileItem
    End If
    LogFolderSummations SourceFolder.Name, SourceFolder.Path, FolderCount, FileCount, ParentID, FolderLevel

    For Each SubFolder In SourceFolder.SubFolders
       ParentID = GetFolderSummationID(SourceFolder.Path)
      'FolderCount = SubFolder.SubFolders.Count
       If (SubFolder.Attributes And 2) <> 2 And (SubFolder.Attributes And 4) <> 4 Then
            SpanFolderSummations SubFolder.Path, ParentID, FolderLevel
       End If
    Next SubFolder
    Set FileItem = Nothing
    Set SourceFolder = Nothing

End Sub
 
I have located where to touch the counts, but each thing you try gives me a different error.
 
What counts are incorrect? Can you send a test folder with some hidden folders and files? Make it smaller than before so it is easy to verify.
 
I send you the database with the changes that I have made, and a folder with four folders and one hidden. If you add the folder to the database, you will see that it marks 5 folders, when it should put 4. It does not appear in the list because I have already removed it.
 

Attachments

And in passing I'm going to ask you another question. He gave you the database again, but this time with a form called 000Form. In it, there is a button that sets a concrete path and opens the frmMS_FormsTree form. Is it possible that when I enter I update automatically without me having to give ReadFiles?
 

Attachments

And finally. Can I do without the two macros AutoExec and CheckTrust? From what I'm seeing, they don't contribute anything.

Thanks a lot!
 
And finally. Can I do without the two macros AutoExec and CheckTrust? From what I'm seeing, they don't contribute anything.
These come with the JPK Treeview and I did not build them. You probably can get rid of them once you built the Tree. However if you import your forms into an existing database you will need to bring these and the modStartup. Or in Vba export the USERFORM UfTreeview and then in VBA reenter. You cannot import this the normal way.

So you are probably better off keeping them until you have your final database.
 
If you include hidden folders you can get that value directly
folderCount = sourcefolder.subfolders.count
If you want to exclude them, you have to loop. Exactly like was done with the files.
Code:
Private Sub SpanFolderSummations(SourceFolderFullName As String, Optional ParentID As Long = 0, Optional ByVal FolderLevel = 0, Optional CountHiddenSystem As Boolean = False)
' lists information about the files in SourceFolder
' example: ListFilesInFolder "C:\FolderName\", True
    'Dim FSO As Object 'Scripting.FileSystemObject
    Dim SourceFolder As Scripting.Folder 'Scripting.Folder
    Dim SubFolder As Scripting.Folder 'Scripting.Folder
    Dim FileItem As Scripting.file 'Scripting.File
    
    Dim FolderCount As Long
    Dim FileCount As Long
    
    FolderLevel = FolderLevel + 1
    Set SourceFolder = FSO.GetFolder(SourceFolderFullName)
    
    If CountHiddenSystem Then
      FolderCount = SourceFolder.SubFolders.Count
    Else
      FolderCount = 0
        For Each SubFolder In SourceFolder.SubFolders
           If (SubFolder.Attributes And 2) <> 2 And (SubFolder.Attributes And 4) <> 4 Then
              FolderCount = FolderCount + 1
           End If
        Next SubFolder
    End If
  
    If CountHiddenSystem Then
         FileCount = SubFolder.Files.Count   'This will count hidden as well
       Else
        FileCount = 0
        
        For Each FileItem In SourceFolder.Files
           If (FileItem.Attributes And 2) <> 2 And (FileItem.Attributes And 4) <> 4 Then
             FileCount = FileCount + 1
           End If
        Next FileItem
        
    End If
    LogFolderSummations SourceFolder.Name, SourceFolder.Path, FolderCount, FileCount, ParentID, FolderLevel

    For Each SubFolder In SourceFolder.SubFolders
       ParentID = GetFolderSummationID(SourceFolder.Path)
      'FolderCount = SubFolder.SubFolders.Count
       If (SubFolder.Attributes And 2) <> 2 And (SubFolder.Attributes And 4) <> 4 Then
            SpanFolderSummations SubFolder.Path, ParentID, FolderLevel
       End If
    Next SubFolder
    Set FileItem = Nothing
    Set SourceFolder = Nothing

End Sub
 
Is it possible that when I enter I update automatically without me having to give ReadFiles?
Of course you can have it span the files automatically. The question is do you really want to do that all the time. Once you have read the directory once you do not have to read again until files/folders have been added or removed. If this is a very big folder you may not want to load every time. If it is small then you might. Look at the code in the OK button of the application settings. It automatically clears the tables, spans, and opens the tree. I have it update everytime you open the form to change the path. I added one more top level procedure to do all of that.

If you are planning to store more than one directory you can do that with some modification. You will need to explain how you like that to work.
 

Attachments

Hi. Look, I am attaching a database of what I want to do.

To do this you would need to know how you could put a list box on a continuous form to select various options, but I will see that later, because it is out of the scope of this post.
 

Attachments

Last edited:
And on the other hand, can the unfolded tree be opened? That is, like this:

ScreenShot002.jpg

To appear like this:

ScreenShot003.jpg

Or tell me how I have to change it.
 
I'm already getting the hang of this. I just got him to remove the Shortcuts through FileItem.Type <> "Shortcut"
 
And could you tell me how to expand, as I explained to you before?
 
And on the other hand, can the unfolded tree be opened? That is, like this:
There is a method to expand the children of a node. I would have to write a method to call that procedure. I would have to look how to code it.
 
There is a method to expand the children of a node. I would have to write a method to call that procedure. I would have to look how to code it.
If you could do it. I don't know how to do it.
 
If you could do it. I don't know how to do it
I am still working this. I tried using the Expanded property but nothing happened.
Are you planning to have 3 directories stored. Music, Videos, Audios? If so in table applicationSettings I would have a way to store the three different top level folders. Modify the Settings form to choose the three paths. When the database opens I would ask the users if they need to rescan the data (a file or folder has been added, deleted, or modified). If "yes" then scan all three folders. Store all data in one table. Have a query for each tree. Then you can quickly show any of the the three trees. If this makes sense can you make me three directories with a few folders and files for test purposes?
 
Hi. Good Morning. First of all, sorry for answering you now. When I received the email telling me that you had responded, it was five in the morning here in Spain. I know there are six hours different from the state of Georgia, because twenty years ago I was taking private English classes with a native of there. So you can get used to the idea of the time difference.

On the other hand, it seems like a very good idea. I have prepared an example of how I have arranged the three folders that I want to scan, with their internal structure as well (I have put some txt as example files, although not in all folders because it was a lot of work). They are the ones with the full name. The ones with only one letter are other folders where I have other files, so you know there are more folders.

Thanks a lot.
 

Attachments

Hi. Good Morning. First of all, sorry for answering you now.
No problem. I am quite aware of the time differences on this forum. I have helped develop large database here for people in New Zealand, Japan, Eastern and Western Europe, South Pacific, South America you name it.
I will take a look later this evening. I have a busy day today.
 

Users who are viewing this thread

Back
Top Bottom