zelarra821
Registered User.
- Local time
- Tomorrow, 00:30
- Joined
- Jan 14, 2019
- Messages
- 835
Hi. I have implemented a search system that I saw in this forum: https://www.access-programmers.co.uk/forums/showthread.php?t=188663.
However, in the form where I have it implemented, when you delete the values of the two fields that you use to run the search, you are left with the last search.
In the form I have several buttons to filter, and I give me that the problem comes out there.
This is the code of the button I use to delete the filters and the search fields:
This is an example of a code to filter:
I also attach a screenshot of how I have mounted the query.
For the tests that I have done, what I need is to reset at the query level the criteria related to the search fields of the form.
Thank you.
However, in the form where I have it implemented, when you delete the values of the two fields that you use to run the search, you are left with the last search.
In the form I have several buttons to filter, and I give me that the problem comes out there.
This is the code of the button I use to delete the filters and the search fields:
Code:
Public Function BorrarFiltros(FName As Form)
FName.FilterOn = False
FName.SearchFor.Value = ""
FName.SrchText.Value = ""
End Function
This is an example of a code to filter:
Code:
Public Function FiltrarPorSeleccion(FName As Form, miSel As String, FiltroForm As String)
On Error Resume Next
Dim miFiltro As String
If Screen.PreviousControl.Name = "Goodreads" Then
FName.Filter = "[Goodreads] = " & FName.Goodreads
FName.FilterOn = True
ElseIf Screen.PreviousControl.Name = "EsSerie" Then
FName.Filter = "[EsSerie] = " & FName.EsSerie
FName.FilterOn = True
ElseIf Screen.PreviousControl.Name = "Biblioteca" Then
FName.Filter = "[Biblioteca] = " & FName.Biblioteca
FName.FilterOn = True
Else
'Comprobamos que se haya escrito algo en el cuadro de texto
If Nz(miSel, "") = "" Then
'Call FiltrarPorNumero(Me)
MsgBox "No has seleccionado nada para buscar", vbInformation, "ERROR"
Exit Function
End If
If Screen.PreviousControl.Name = "Autor" Then
miFiltro = "Autor1" & " LIKE '*" & miSel & "*'"
ElseIf Screen.PreviousControl.Name = "Subgenero" Then
miFiltro = "Subgenero1" & " LIKE '*" & miSel & "*'"
ElseIf Screen.PreviousControl.Name = "Formato" Then
miFiltro = "Formato1" & " LIKE '*" & miSel & "*'"
ElseIf Screen.PreviousControl.Name = "Serie" Then
miFiltro = "Serie1" & " LIKE '*" & miSel & "*'"
Else
'Cojemos el valor seleccionado y el campo y creamos el filtro por aproximación
miFiltro = Screen.PreviousControl.Name & " LIKE '*" & miSel & "*'"
End If
'Aplicamos el filtro al formulario
If FiltroForm = "" Then
FiltroForm = miFiltro
FName.Filter = miFiltro
FName.FilterOn = True
Else
FName.Filter = "(" & FiltroForm & ") And (" & miFiltro & ")"
FName.FilterOn = True
End If
End If
End Function
I also attach a screenshot of how I have mounted the query.
For the tests that I have done, what I need is to reset at the query level the criteria related to the search fields of the form.
Thank you.