Vous êtes sur la page 1sur 3

Option Compare Database 'Utilise l'ordre de la base données pour les comparaisons de chaînes

Option Explicit

Const conErrÉtatAnnulé = 2501

Private Sub Annuler_Click()


' Ferme le formulaire. (Ce code est créé par l'Assistant Bouton de commande.)
On Error GoTo Err_Annuler_Click

DoCmd.Close

Exit_Annuler_Click:
Exit Sub

Err_Annuler_Click:
MsgBox Err.Description
Resume Exit_Annuler_Click

End Sub

Private Sub DéfinirDate_Click()

On Error GoTo DéfinirDate_Error

If DéfinirDate.Caption = "Définir une date de début" Then


[Date début] = SélectionnerDate.Value
DéfinirDate.Caption = "Définir une date de fin"
Else
[Date fin] = SélectionnerDate.Value
DéfinirDate.Caption = "Définir une date de début"
End If

Exit Sub

DéfinirDate_Error:
MsgBox Err.Description
Exit Sub
End Sub

Private Sub Form_Activate()

' Cacher la barre d'outils intégrée Mode Formulaire.


DoCmd.ShowToolbar "Mode Formulaire", acToolbarNo

End Sub
Private Sub Form_Load()

' Utilisé par Solutions du développeur pour renvoyer des enregistrements pour exemple.
' Entrez les paramètres [Date début] et [Date fin] quand le formulaire est chargé.
Me!SélectionnerDate = #6/12/2012#
Me![Date début] = #6/12/2012#
Me![Date fin] = #6/20/2012#

End Sub

Private Sub Aperçu_Click()


' Aperçu de l'état.
Dim chNomDocument As String

On Error GoTo Err_Aperçu_Click

' Vérifie si la date de fin est postérieure à la date de début.


If IsDate([Date début]) And IsDate([Date fin]) Then
If [Date fin] < [Date début] Then
MsgBox "La date de fin doit être postérieure à la date de début."
DéfinirDate.Caption = "Définir une date de fin"
DéfinirDate.SetFocus
Exit Sub
End If
Else
MsgBox "Utilisez une date valide pour les valeurs des dates de début et de fin."
Exit Sub
End If

chNomDocument = "Ventes des employés"


DoCmd.OpenReport chNomDocument, acViewPreview

' Utilisé par Solutions du développeur pour ouvrir la rubrique Montrez-moi pour l'état.
If EstChargé("Solutions du développeur") Then
If Forms![Solutions du développeur]![Montrez-moi] Then
AfficherAideAPI
End If
End If

Exit_Aperçu_Click:
Exit Sub

Err_Aperçu_Click:
If Err = conErrÉtatAnnulé Then
Resume Exit_Aperçu_Click
Else
MsgBox Err.Description
Resume Exit_Aperçu_Click
End If

End Sub

Private Sub Imprimer_Click()


' Imprimer l'état.
Dim chNomDocument As String

On Error GoTo Err_Imprimer_Click

' Vérifie si la date de fin est postérieure à la date de début.


If [Date fin] < [Date début] Then
MsgBox "La date de fin doit être postérieure à la date de début."
DéfinirDate.Caption = "Définir une date de fin"
DéfinirDate.SetFocus
Exit Sub
End If

chNomDocument = "Ventes des employés"


DoCmd.OpenReport chNomDocument, acViewNormal

Exit_Imprimer_Click:
Exit Sub

Err_Imprimer_Click:
If Err = conErrÉtatAnnulé Then
Resume Exit_Imprimer_Click
Else
MsgBox Err.Description
Resume Exit_Imprimer_Click
End If

End Sub

Vous aimerez peut-être aussi