Comment faire un filtre dans une requête
Bonjour tous!
je voudrais avoir votre aide concernant un problème sur Access.
Je voudrais à partir d'un bouton envoyer un inputbox dans lequel l'utilisateur saisira un numero qui, après qu'il ait cliqué sur le "ok", sera utilisé comme critère de filtre dans une requête déjà constituée (nom de la requête: RECHERCHE REGLEMENT).
En gros, je souhaiterais faire un filtre dans une requete à partir de l'information renseignée dans le inputbox.
Trouver en dessous mon code et merci d'avance:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub Commande16_Click()
Dim police As String
police = InputBox("Entrer le N°Police SVP!", "Vérification N°Police")
If police = "" Then
While police = ""
police = InputBox("Entrer le N°Police SVP!", "Vérification N°Police")
If police = "" Then
MsgBox "Aucun N°Police a été saisi"
Else
DoCmd.ApplyFilter , "[NUM GAR_POL]=" & police
DoCmd.OpenQuery "RECHERCHE REGLEMENT"
End If
Wend
Else
If Not IsNull(police) Then
DoCmd.ApplyFilter , "[NUM GAR_POL]=" & police
DoCmd.OpenQuery "RECHERCHE REGLEMENT"
End If
End If
If police <> 0 Then
DoCmd.ApplyFilter , "[NUM GAR_POL]=" & police
DoCmd.OpenQuery "RECHERCHE REGLEMENT"
End If
End Sub |