1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| 'AMELIORATION: tri par liste déroulante récupérant automatiquement tous les mots clés de chauque record de la table [Info Intéressante]
Dim tabSearch() As String 'les n mots sont donc renvoyer grâce à tabSearch(0) à tabSearch(n)
Dim i As Integer
If Me.Texte27 <> "" Then
'découpe la chaine en fonction des espaces " ", le résultat de la fonction Split est stocké dans un tableau
tabSearch = Split(Me.[Texte27], " ")
For i = 0 To UBound(tabSearch) 'boucle
Next i 'MsgBox i en sortie de boucle renvoi le nombre de ligne +1 dans la table temporaire Split (= nb de mots à chercher quoi)
'MsgBox i
Else
MsgBox "Aucun mot à rechercher"
End If
If i = 1 Then
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE (RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True);"
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Aucun enregistrement correspondant à votre recherche n'a été trouvé"
Me.RecordSource = "SELECT * FROM TableTriPersonnaliséSQL LEFT JOIN [Info intéressante] ON TableTriPersonnaliséSQL.[Degré d'importance] = [Info intéressante].[Degré d'intérêt] ORDER BY TableTriPersonnaliséSQL.TriPersonnalisé DESC;"
End If
ElseIf i = 2 Then
If Me.Cadre51 = 1 Then 'cas OU
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True));"
ElseIf Me.Cadre51 = 2 Then 'cas ET
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True));"
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Aucun enregistrement correspondant à votre recherche n'a été trouvé"
Me.RecordSource = "SELECT * FROM TableTriPersonnaliséSQL LEFT JOIN [Info intéressante] ON TableTriPersonnaliséSQL.[Degré d'importance] = [Info intéressante].[Degré d'intérêt] ORDER BY TableTriPersonnaliséSQL.TriPersonnalisé DESC;"
End If
ElseIf i = 3 Then
If Me.Cadre51 = 1 Then 'cas OU
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True));"
ElseIf Me.Cadre51 = 2 Then 'cas ET
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True));"
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Aucun enregistrement correspondant à votre recherche n'a été trouvé"
Me.RecordSource = "SELECT * FROM TableTriPersonnaliséSQL LEFT JOIN [Info intéressante] ON TableTriPersonnaliséSQL.[Degré d'importance] = [Info intéressante].[Degré d'intérêt] ORDER BY TableTriPersonnaliséSQL.TriPersonnalisé DESC;"
End If
ElseIf i = 4 Then
If Me.Cadre51 = 1 Then 'cas OU
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(3) & "') = True));"
ElseIf Me.Cadre51 = 2 Then 'cas ET
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(3) & "') = True));"
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Aucun enregistrement correspondant à votre recherche n'a été trouvé"
Me.RecordSource = "SELECT * FROM TableTriPersonnaliséSQL LEFT JOIN [Info intéressante] ON TableTriPersonnaliséSQL.[Degré d'importance] = [Info intéressante].[Degré d'intérêt] ORDER BY TableTriPersonnaliséSQL.TriPersonnalisé DESC;"
End If
ElseIf i = 5 Then
If Me.Cadre51 = 1 Then 'cas OU
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(3) & "') = True) or (RechercheMot([Info] & [Mots clés], '" & tabSearch(4) & "') = True));"
ElseIf Me.Cadre51 = 2 Then 'cas ET
Me.RecordSource = "SELECT * FROM [Info intéressante] WHERE ((RechercheMot([Info] & [Mots clés], '" & tabSearch(0) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(1) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(2) & "') = True) and (RechercheMot([Info] & [Mots clés], '" & tabSearch(3) & "') = True) & and (RechercheMot([Info] & [Mots clés], '" & tabSearch(4) & "') = True));"
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "Aucun enregistrement correspondant à votre recherche n'a été trouvé"
Me.RecordSource = "SELECT * FROM TableTriPersonnaliséSQL LEFT JOIN [Info intéressante] ON TableTriPersonnaliséSQL.[Degré d'importance] = [Info intéressante].[Degré d'intérêt] ORDER BY TableTriPersonnaliséSQL.TriPersonnalisé DESC;"
End If
ElseIf i > 5 Then
MsgBox "Nombre de mots trop important (> 5)"
End If |
Partager