zelarra821
Registered User.
- Local time
- Today, 01:56
- Joined
- Jan 14, 2019
- Messages
- 834
Good afternoon. I am trying to make a search engine in a form, but it took several days, and I can't find a possible solution.
I have this:
https://www.dropbox.com/s/jmc4yg5m8qs2jwt/ScreenShot001.jpg?dl=0
I'm going to focus on dropdowns, not checkboxes, which I also use to filter. I think that if I remove the dropdowns, it will not cost me to include the checkboxes.
There are three possible filters:
Estado > Formato > Género > Subgénero (Status> Format> Genre> Subgenre)
Año Añadido > Mes Añadido (Year Added> Month Added)
Año Leído > Mes Leído (Year Read> Month Read)
To simplify it further, and make the answer easier, let's just take the first two (state and year added).
I want that, if I choose a status, it shows me only the related records of the added year, and vice versa, that is, if I choose an added year, it shows me the related records of the status. Also, that then allows me to filter the dropdowns that depend on these (namely, format, which depends on status; and added month, which depends on the added year)
Finally, I want to add a second column in each dropdown with the number of values for each option. So:
https://www.dropbox.com/s/uhum6muftz1hchn/ScreenShot002.jpg?dl=0
How have I tried to do it?
The way to get it that she had thought was by using the column with the number of records. In this way, in the origin query of the drop-down, I would put a condition that it only show those that were greater than zero, and it would already have it.
Now, how do I get that value for the second column of the dropdown?
I have this code:
And that FilterCombo function is this:
I have to say that AñoAñadido is not a field in the table, but I calculate it based on the date.
When I do it that way, the second column with the number of records from the second dropdown shows me as if I had not applied any filter. In the image, the number of records in the form is two after having applied the status filter, but in the drop-down of the added year it shows me all (in this case, I would only have to leave 2019 - 2)
https://www.dropbox.com/s/uu20hy38safts6j/ScreenShot003.jpg?dl=0
Another thing that I would like to achieve is that, when I choose a value from this second drop-down and go back in to choose another option, all the options will indeed appear. That is, if I choose the Buy Status, and for the Year Added drop-down it tells me that only the years 2019 and 2020 are available, that when I choose 2019, when I redeploy the two years will appear, and not just the one I have chosen.
I don't know if there will be a simpler option. I believe that this one that I propose is not too complicated. Where I have the problem is when creating the filter for the second column with the number of records.
I attach a demo if you want to try something. Let's see if someone could give me an example of how I would have to do it, to develop it myself.
Thank you!
I have this:
https://www.dropbox.com/s/jmc4yg5m8qs2jwt/ScreenShot001.jpg?dl=0
I'm going to focus on dropdowns, not checkboxes, which I also use to filter. I think that if I remove the dropdowns, it will not cost me to include the checkboxes.
There are three possible filters:
Estado > Formato > Género > Subgénero (Status> Format> Genre> Subgenre)
Año Añadido > Mes Añadido (Year Added> Month Added)
Año Leído > Mes Leído (Year Read> Month Read)
To simplify it further, and make the answer easier, let's just take the first two (state and year added).
I want that, if I choose a status, it shows me only the related records of the added year, and vice versa, that is, if I choose an added year, it shows me the related records of the status. Also, that then allows me to filter the dropdowns that depend on these (namely, format, which depends on status; and added month, which depends on the added year)
Finally, I want to add a second column in each dropdown with the number of values for each option. So:
https://www.dropbox.com/s/uhum6muftz1hchn/ScreenShot002.jpg?dl=0
How have I tried to do it?
The way to get it that she had thought was by using the column with the number of records. In this way, in the origin query of the drop-down, I would put a condition that it only show those that were greater than zero, and it would already have it.
Now, how do I get that value for the second column of the dropdown?
I have this code:
Code:
Function Veces(Tipo As String, Filtro As String) As Integer
Dim myFilter1 As String
Dim rst As DAO.Recordset
Dim Veces1 As String
FilterCombo Tipo, Filtro, "Buscador"
Veces1 = "SELECT Count(CQuery.Titulo1) AS Veces" _
& " FROM (" & myRecordSource & ") As CQuery" _
& IIf(myFilterCombo = "", "", " WHERE " & myFilterCombo & "")
Set rst = CurrentDb.OpenRecordset(Veces1)
If Not (rst.EOF And rst.BOF) Then
Veces = rst("Veces")
End If
rst.Close
Set rst = Nothing
End Function
And that FilterCombo function is this:
Code:
Sub FilterCombo(Tipo As String, Filtro As String, Optional Formulario As String = "")
myFilterCombo = ""
Select Case Formulario
Case "Buscador"
If Tipo = "Estado" Then
If myFilterCombo <> "" Then myFilterCombo = myFilterCombo & " And "
myFilterCombo = myFilterCombo & Filtro
End If
End Select
If Tipo = "AñoAñadido" Then
If myFilterCombo <> "" Then myFilterCombo = myFilterCombo & " And "
myFilterCombo = myFilterCombo & Filtro
End If
End Sub
I have to say that AñoAñadido is not a field in the table, but I calculate it based on the date.
When I do it that way, the second column with the number of records from the second dropdown shows me as if I had not applied any filter. In the image, the number of records in the form is two after having applied the status filter, but in the drop-down of the added year it shows me all (in this case, I would only have to leave 2019 - 2)
https://www.dropbox.com/s/uu20hy38safts6j/ScreenShot003.jpg?dl=0
Another thing that I would like to achieve is that, when I choose a value from this second drop-down and go back in to choose another option, all the options will indeed appear. That is, if I choose the Buy Status, and for the Year Added drop-down it tells me that only the years 2019 and 2020 are available, that when I choose 2019, when I redeploy the two years will appear, and not just the one I have chosen.
I don't know if there will be a simpler option. I believe that this one that I propose is not too complicated. Where I have the problem is when creating the filter for the second column with the number of records.
I attach a demo if you want to try something. Let's see if someone could give me an example of how I would have to do it, to develop it myself.
Thank you!