Solved Multiple search engine with dropdowns (1 Viewer)

Dreamweaver

Well-known member
Local time
Today, 14:21
Joined
Nov 28, 2005
Messages
2,466
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
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
I have located where to touch the counts, but each thing you try gives me a different error.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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.
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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

  • Database.zip
    3 KB · Views: 125
  • LogFileDirectory V1.accdb
    1.5 MB · Views: 112

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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

  • LogFileDirectory V1.accdb
    2.1 MB · Views: 112

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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

  • VideosLog.accdb
    1.1 MB · Views: 196

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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

  • What I want to do.accdb
    2.4 MB · Views: 128
Last edited:

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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.
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
I'm already getting the hang of this. I just got him to remove the Shortcuts through FileItem.Type <> "Shortcut"
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
And could you tell me how to expand, as I explained to you before?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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.
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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?
 

zelarra821

Registered User.
Local time
Today, 15:21
Joined
Jan 14, 2019
Messages
809
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

  • My Documents.zip
    498.3 KB · Views: 113

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:21
Joined
May 21, 2018
Messages
8,527
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

Top Bottom