Solved Multiple search engine with dropdowns (2 Viewers)

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
Finally figured it out. I did not see that you had these as FAYT comboboxes as well.
Unfortunately you cannot just requery a FAYT combobox. I need to add some notes to the class. You have to set the the rowsource of the FAYT.
I thought I was going crazy.


Code:
Public Function FilterRequery()
  On Error Resume Next
  UpdateDynamicQuery
  ActiveControl.Requery
 
  'When you requery a FAYT you need to set the resource of the FAYT.  Requerying the related combo is not enough.
  cmbEstado.RowSource = Me.CodigoEstado.RowSource
  cmbCategoria.RowSource = Me.CodigoCategoria.RowSource
  cmbSubcategoria.RowSource = Me.CodigoSubcategoria.RowSource


  DoEvents
  Me.Refresh
  Me.Repaint
End Function

These classes are nice because they are extremely flexible and reuseable to allow you to filter a form or a combobox as a FAYT.
In truth where you are tying the FAYT form and the FAYT combos to other filters, it may have caused more problems. Trying to get all of this to work together may have been easier with hardcoding the FAYT features.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
I added a requery method to the FAYT combos. You still must requery the FAYT object and not just the combobox. I think there are still some issues, but this is closer.
 

Attachments

  • Database3 MajP.zip
    289.7 KB · Views: 109

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
Here I have solved the error that CodigoEstado gave.

Now when you enter the form, it should show all the records from CodigoMultimedia, and it doesn't.

And I think the categories are not showing them well. You just have to look at Category12 and Category29 in the table, and you will see that it does not add up well in the form.
 

Attachments

  • Database3 MajP.accdb
    2 MB · Views: 121

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
Look, this I think is the problem that remains.

If I have two categories that are called the same, but they go in different CodigoMultimedia, the system goes crazy. Look at Categoria11. One has CodigoMultimedia 6 and another 7, and it doesn't filter correctly.
 

Attachments

  • Database3 MajP.accdb
    1 MB · Views: 109

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
I have already managed to fix everything except the video that I attached to you in the previous post, when two categories have the same name, but belong to different Multimedia Code.

Once that is fixed, everything else works perfectly.

It remains to be seen how we can get those file / folder values.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
I was just thinking simple labels.
 

Attachments

  • Database5MajP.accdb
    1 MB · Views: 128

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
You're right, I hadn't understood you at all. Sorry.

One last thing. When I told you to show a second count for the "folders", how did you think it could be done? That is, how would you put it?

Thank you.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
Can you show a simple example of a folder? I am not sure what that means. What fields hold folder information?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
So these are real files on your system? You want to count the real folders in the directory. Are they multiple levels? If they are a tree structure you have to do a recursive call.

Code:
Folder
  SubFolder
  SubFolder
  ....
  SubFolder

Counting the number of subfolders is simple.
Code:
Folder
  SubFolder
    SubSubFolder
    SubSubFolder
  SubFolder
    SubSubFolder
    SubSubFolder
  ....
  SubFolder
Counting the nested subsubfolders is more difficult in that you need a recursive call. Something like
Code:
Function getFileCount(localRoot, Optional fld, Optional count As Long) As Long
    Dim fso, f, baseFolder, subFolder, ftpFile, i

    Set fso = CreateObject("Scripting.Filesystemobject")

    If IsMissing(fld) Then
        Set baseFolder = fso.GetFolder(localRoot)
    Else
        Set baseFolder = fld
    End If

    count = count + baseFolder.Files.count

    For Each subFolder In baseFolder.SubFolders
        getFileCount localRoot, subFolder, count     'NOTICED THE RECURSIVE CALL HERE. The function calls itself.
    Next

    getFileCount = count
End Function

I think I need details of where the folders are going to be located, the folder structure, and what you want to count. Can you post an expanded "Tree View" of the folders?
 

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
I have created the tree that I have on my laptop, but only Descargado, because I delete the Reproducido and they only remain for the purposes of annotation in the database.

The files are not real, but they are equal to them in number, which is the important thing.

If you want to know the extension, I will tell you that they are mp4, that's why I pass you txt representing those videos.

I have reproduced you all the levels.

In Excel, I show you the count that must be given to Multimedia, because Categoria and Subcategoria depend on the Multimedia that is chosen, and there are many variables.

The path where they will be hosted in the root of drive D, although this I suppose I can change later.

What I count are files and folders.

I think I have mounted it should be worth to understand what I want.

One thing: the count was done on the data in the database, to manually compare with what really had on the computer and check that it matched. That is why I wanted to do something later on to what you propose, to automate it. So I don't know if there is any way to check that what is in the database matches what is on the computer, although I can imagine.

If you think that what I want can be structured differently, I am open to new possibilities.

Thanks!
 

Attachments

  • Database.zip
    398.1 KB · Views: 108

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
Would you like a small pop up that shows the information in a tree? It would be not much harder, but may allow the user to explore.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
Not certain how you want to get and show and use this information. The pieces are all there.
1. I read and store all the information so that I can make the tree view. This takes about 10 seconds to populate.
2. If you do not want to store all information then you could just get the folder and file counts, but you will still have to write that to a table.
3. I get the counts after the fact.

With the tree you know could actually execute those files with a double click or another event.

Tree.jpg

The Top is the tree the lower shows the counts. As you can see it is correct. Descargado has 6 folders. Reproducido has no items. Tipo1 is inside of Descardado and has 16 files.

The problem with storing the detail information is that you have to delete and reload. This could happen automatically when you open the DB. However the DB will need to get compacted often with that many deletes.

The code to do this is actually extremely short. Half of that is simple helper functions
Code:
Public Sub InitializeSpan()
  Set FSO = New FileSystemObject
  SpanFolders GetDefaultFolderFullName, 0
  Set FSO = Nothing
End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'************************************************************************  Span Folders  *********************************************************************************
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub SpanFolders(SourceFolderName As String, 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

    Dim strAddress As String
    Dim strDisplayText As String
    FolderLevel = FolderLevel + 1
    Set SourceFolder = FSO.GetFolder(SourceFolderName)
       ParentID = GetParentID(SourceFolder.Name)
       For Each SubFolder In SourceFolder.SubFolders
       LogFilesFolders SubFolder.Name, SubFolder.Path, SubFolder.Type, ParentID, fft_Folder, FolderLevel
       SpanFolders SubFolder.Path, FolderLevel
    Next SubFolder

    For Each FileItem In SourceFolder.Files
       LogFilesFolders FileItem.Name, FileItem.Path, FileItem.Type, ParentID, fft_File, FolderLevel
    Next FileItem
    Set FileItem = Nothing
    Set SourceFolder = Nothing

End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'************************************************************************  Wrapper Functions  *********************************************************************************
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Public Function GetDefaultFolderPath()
  'For Demo use the current project path
  'If not you would read from the applications table
  GetDefaultFolderPath = CurrentProject.Path
End Function

Public Function GetDefaultFolderName()
  GetDefaultFolderName = DLookup("defaultFolderName", "tblApplicationSettings")
End Function

Public Function GetDefaultFolderFullName()
  GetDefaultFolderFullName = GetDefaultFolderPath & "\" & GetDefaultFolderName
End Function

Public Function GetParentID(ByVal ParentName As String) As Long
  GetParentID = Nz(DLookup("FolderFileID", "tblFoldersFiles", "FolderFileName = " & CSql(ParentName)), 0)
End Function
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'************************************************************************  Logging Functions  *********************************************************************************
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub LogFilesFolders(ItemName As String, ItemFullName As String, ItemType As String, ParentID As Long, FolderOrFile As FileFolderType, FolderLevel)
  Dim TheFields As String
  Dim strFolderOrFile As String
  Const TableName = "tblFoldersFiles"

  TheFields = insertFields("FolderFileName", "FolderFileFullName", "FolderOrFile", "ParentFolderID", "FileType", "FolderLevel")
  Select Case FolderOrFile
    Case fft_Folder
      strFolderOrFile = "Folder"
    Case fft_File
      strFolderOrFile = "File"
   End Select
   ParamInsert TableName, TheFields, ItemName, ItemFullName, strFolderOrFile, ParentID, ItemType, FolderLevel
End Sub
To see this work click the buttons in order.
1. Clear out the table
2. Read all your files
3. Show the treeview. (I should have done this automatically)

The entire code for loading the treeview is this
Code:
Public WithEvents TVW As TreeviewForm

Private Sub cmdFiles_Click()
  TVW.Initialize Me.xTree.Object, "qryFolderTree", "0FolderFiles"
End Sub

The beuaty of class modules. Build once use often.
 

Attachments

  • ReadFiles.zip
    3.7 MB · Views: 142
Last edited:

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
Thanks a lot. However, I cannot see it because I am missing the reference. I am trying to fix it and there is no way. Could you send me this file that appears in the screenshot?
 

Attachments

  • ScreenShot001.jpg
    ScreenShot001.jpg
    519.8 KB · Views: 96

zelarra821

Registered User.
Local time
Today, 19:04
Joined
Jan 14, 2019
Messages
813
I ask you first so that you can pass me the file, to see if it is fixed, because if not, what you have happened to me is not worth it because I cannot use it. If I can fix it, I'll ask you a couple of questions about its use.

Thank you!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
OCX.jpg


References > Browse > (windows System 32)
Make sure to change the file filter to ("ActiveX Controls (*.OCX)"). See bottom right of image
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:04
Joined
May 21, 2018
Messages
8,555
Loading the Tree has some costs, because it requires you to load all the files. As said this takes about 9 seconds for 1300+ files. So it will take more time if you have more, but this can be done at startup and you could provide a progress meter. Then you have the issue of deleting files. This could be mitigated by only adding and deleting changes. That may increase the time but solve the problem of needing to compact the database for all of the deletes.

If you really only need the counts, this can be obviously much faster since you would only likely have 100s of folders instead of thousands of folders and files.
 

Users who are viewing this thread

Top Bottom