Function getFilter(FName As Form, FAYTform As FindAsYouTypeForm_NoAuto) As String
Dim strFltr As String
Dim strDuracion As String
Dim strFAYT As String
Dim strEstado As String
Dim strMultimedia As String
Dim strCategoria As String
Dim strSubGenero As String
Dim ctrl As Access.Control
On Error GoTo errlbl
strDuracion = GetBetweenFilter(FName.SrchDuracionMin, FName.SrchDuracionMax, "Duracion", sdt_date)
For Each ctrl In FName.Controls
If ctrl.controlType = acComboBox And ctrl.Tag = "Filter" Then ctrl.Requery
Next ctrl
strEstado = GetFilterFromControl(FName.CodigoEstado, , , 2)
strMultimedia = GetFilterFromControl(FName.CodigoTipoMultimedia, , , 2)
strCategoria = GetFilterFromControl(FName.CodigoCategoria, , , 2)
strSubGenero = GetFilterFromControl(FName.CodigoSubcategoria, , , 2)
strFltr = CombineFilters(ct_And, strDuracion, strEstado, strMultimedia, strCategoria, strSubGenero)
strFAYT = FAYTform.Filter
If strFltr <> "" And strFAYT <> "" Then
strFltr = strFltr & " AND (" & strFAYT & ")"
ElseIf strFltr = "" And strFAYT <> "" Then
strFltr = strFAYT
End If
Select Case Screen.ActiveControl.Name
Case "CodigoEstado"
strFltrCombo = CombineFilters(ct_And, strDuracion, strMultimedia, strCategoria, strSubGenero)
Case "CodigoTipoMultimedia"
strFltrCombo = CombineFilters(ct_And, strDuracion, strEstado, strCategoria, strSubGenero)
Case "CodigoCategoria"
strFltrCombo = CombineFilters(ct_And, strDuracion, strEstado, strMultimedia, strSubGenero)
Case "CodigoSubcategoria"
strFltrCombo = CombineFilters(ct_And, strDuracion, strEstado, strMultimedia, strCategoria)
End Select
err2474Resume:
If strFltrCombo <> "" And strFAYT <> "" Then
strFltrCombo = strFltrCombo & " AND (" & strFAYT & ")"
ElseIf strFltrCombo = "" And strFAYT <> "" Then
strFltrCombo = strFAYT
End If
getFilter = strFltr
Debug.Print "Overal Filter " & strFltr
Debug.Print "combo filter 2 " & strFltrCombo
GetDynamicQuery "CFormFilterVideos", "CDynamicFilterVideos", strFltrCombo
Exit Function
errlbl:
If Err.Number = 2474 Then
GoTo err2474Resume
Else
MsgBox Err.Number & " " & Err.Description & " In Getfilter"
End If
End Function