Salut à tous,
J'ai crée un rapport et quand on l'ouvre, il y a un petit formulaire de filtrage qui s'ouvre ce qui permet de filtrer le rapport selon les données qu'on veut voir. Le problème, c'est que je n'arrive pas à comprendre pourquoi ça ne marche pas car j'ai identifié toutes mes variables, or chaque fois que je clique sur le bouton "Set filter" (Appliquer filtre), ca me ramène au module de débogage.
Voici mon 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| Option Compare Database
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
' strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property
Reports![RptBy2].Filter = strSQL
Reports![RptBy2].FilterOn = True
Else
Reports![RptBy2].FilterOn = False
End If
End Sub
Private Sub Clear_Click()
Dim intCounter As Integer
For intCounter = 1 To 5
Me("Filter" & intCounter) = ""
Next
End Sub
Private Sub Close_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Private Sub Form_Close()
DoCmd.Close acReport, "RptBy2" 'Close the BY report.
DoCmd.Restore 'Restore the window size
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "RptBy2", A_PREVIEW 'Open BY report.
DoCmd.Maximize 'Maximize the report window
End Sub |
Dans le débogueur, le message en jaune est le suivant
If Me("Filter" & intCounter) <> "" Then
Je ne sais donc pas ou ca peut être le problème.
vautour29
Partager