Bonsoir,

J'ai un sous-form basé sur la requête suivante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
SELECT Iif(Count(AFFAIRES.Réfaffaires)=0,"-",Count(AFFAIRES.Réfaffaires))
FROM AFFAIRES
WHERE Month([Signature définitive prévue le])=Month(Date())
HAVING (((AFFAIRES.[Transaction en cours])=True));
J'ai le bouton de commande de l'ouverture de l'état correspondant et je voudrais, s'il n'y a rien à afficher (donc resultat de ma requête ="-") avoir un message d'info. j'ai tenté ça (en tatonnant, ne connaissant pas tous les rouages d'access) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Private Sub Commande251_Click()
If Me.Nbrencours="-" then
Msgbox "Il n'y a rien à afficher",vbInformation+vbOkonly,"INFORMATION"
Else
On Error GoTo Err_Commande251_Click
    Dim stDocName As String
 
    stDocName = "ENCOURS DU MOIS"
    DoCmd.OpenReport stDocName, acPreview
 
Exit_Commande251_Click:
    Exit Sub
 
Err_Commande251_Click:
    MsgBox Err.Description
    Resume Exit_Commande251_Click
End If
End Sub
Vous vous doutez bien que ça ne marche pas...

Help