oui le code VBA du formulaire.
Private Sub Form_Current()
'Me.Caption = "Facture au nom de " & Forms!Clients![Nom]
If Me![ImpRem] = -1 Then
Me!Commande46.Visible = True
Me!Image55.Visible = True
End If
End Sub
=========================================
Private Sub Form_Open(Cancel As Integer)
Me.Caption = "Facture au nom de " & Forms!Clients![Nom]
If Me![TF] = "FEX" Then
Me![PCBENUM].Enabled = True
Me![Montant pcbe].Enabled = True
End If
If Me![TF] = "FCA" Then
Me![Cadre48].Visible = True
ElseIf Me![TF] = "FEX" Then
Me![Cadre48].Visible = False
ElseIf Me![TF] = "FME" Then
Me![Cadre48].Visible = False
End If
If Me![Remarque] = -1 Then
Me![Commande46].Visible = True
End If
End Sub
=============================================
Private Sub Form_Close()
DoCmd.OpenForm "clients", acNormal, "", "[NCL] = [Forms]![FacturesExMeCa]![NCL]"
End Sub
==============================================
Private Sub Form_Unload(Cancel As Integer)
Dim FME As Form, maBD As Database, rstVentilation As Recordset
Dim critere, vBookmark As Variant
Set maBD = CurrentDb
Set rstVentilation = maBD.OpenRecordset("Ventilation", dbOpenDynaset)
Set FME = Forms![FacturesExMeCa]
critere = "Numfact= " & FME![Numfact]
If IsNull(Me![Date facture]) Then
Beep
MsgBox "Vous avez omis la date !", vbCritical, "Date facture"
DoCmd.CancelEvent
Me![Date facture].SetFocus
End If
With rstVentilation
If .RecordCount = 0 Then
.AddNew
!Numfact = FME![Numfact]
!NfactLettre = FME![NfactLettre]
!DateFacture = FME![Date facture]
!NCL = FME![NCL]
!NomFamille = FME![Nom]
!TotAccessoires = FME![SousFacture]![SommeMtAccessoires]
!TotBatteries = FME![SousFacture]![SommeMtBatteries]
!TotPneus = FME![SousFacture]![SommeMtPneus]
!TotHuiles = FME![SousFacture]![SommeMtHuiles]
!QtéHuiles = FME![SousFacture]![SommeQtéHuiles]
!QtéPneus = FME![SousFacture]![SommeQtéPneus]
!QtéBatteries = FME![SousFacture]![SommeQtéBatt]
!MO = FME![MO]
!RemiseTotale = FME![SousFacture]![RemiseTotale]
!TotalTVA = FME![TotalTVA]
If FME![Taux TVA] = 0.21 Then
![Base6%] = 0
![Base21%] = FME![base%]
ElseIf FME![Taux TVA] = 0.06 Then
![Base21%] = 0
![Base6%] = FME![base%]
End If
!MontantAPayer = FME![Texte20]
.Update
.Close
ElseIf .RecordCount > 0 Then
.MoveFirst
.FindFirst critere
If .NoMatch Then
.AddNew
!Numfact = FME![Numfact]
!NfactLettre = FME![NfactLettre]
!DateFacture = FME![Date facture]
!NCL = FME![NCL]
!NomFamille = FME![Nom]
!TotAccessoires = FME![SousFacture]![SommeMtAccessoires]
!TotBatteries = FME![SousFacture]![SommeMtBatteries]
!TotPneus = FME![SousFacture]![SommeMtPneus]
!TotHuiles = FME![SousFacture]![SommeMtHuiles]
!QtéHuiles = FME![SousFacture]![SommeQtéHuiles]
!QtéPneus = FME![SousFacture]![SommeQtéPneus]
!QtéBatteries = FME![SousFacture]![SommeQtéBatt]
!MO = FME![MO]
!RemiseTotale = FME![SousFacture]![RemiseTotale]
!TotalTVA = FME![TotalTVA]
If FME![Taux TVA] = 0.21 Then
![Base6%] = 0
![Base21%] = FME![base%]
ElseIf FME![Taux TVA] = 0.06 Then
![Base21%] = 0
![Base6%] = FME![base%]
End If
!MontantAPayer = FME![Texte20]
.Update
.Close
ElseIf Not .NoMatch Then
'msgbox "J'ai trouvé " & NumFact
vBookmark = Me.Bookmark
.Edit
' !NomFamille = FME![Nom]
!NCL = FME![NCL]
!NfactLettre = FME![NfactLettre]
!DateFacture = FME![Date facture]
!TotAccessoires = FME![SousFacture]![SommeMtAccessoires]
!TotBatteries = FME![SousFacture]![SommeMtBatteries]
!TotPneus = FME![SousFacture]![SommeMtPneus]
!TotHuiles = FME![SousFacture]![SommeMtHuiles]
!QtéHuiles = FME![SousFacture]![SommeQtéHuiles]
!QtéPneus = FME![SousFacture]![SommeQtéPneus]
!QtéBatteries = FME![SousFacture]![SommeQtéBatt]
!MO = FME![MO]
!RemiseTotale = FME![SousFacture]![RemiseTotale]
!TotalTVA = FME![TotalTVA]
If FME![Taux TVA] = 0.21 Then
![Base6%] = 0
![Base21%] = FME![base%]
ElseIf FME![Taux TVA] = 0.06 Then
![Base21%] = 0
![Base6%] = FME![base%]
End If
!MontantAPayer = FME![Texte20]
.Update
.Close
End If
End If
End With
FME![MontantAPayer] = FME![Texte20]
If FME!Image55.Picture <> "" Then
FME!Image55.Visible = True
End If
Set FME = Nothing
Set maBD = Nothing
Set rstVentilation = Nothing
End Sub
==========================================
Maintenant, autre chose :-)
Je voudrais centrer un formulaire.
Je n'y arrive pas.
Le seul moyen est de dire que le formulaire est indépendant, mais alors, je perds la commande compléments. :-(
@+