Salut à quel endroit je change le format date:
C'est dans ce ufconsultation que ca plante
Dim modi As Boolean
Dim varcap As String
Dim varnum As String
Private Sub Cbbateau_Change()
lig = Me.Cbbateau.ListIndex + 2
varcap = Sheets("BD bateau").Cells(lig, 3).Value 'colonne 9
varnum = Sheets("BD bateau").Cells(lig, 2).Value 'colonne 10
End Sub
Private Sub cmdEnrg_Click()
If Me.cbxChoixDate.ListIndex = -1 Then
nuli = Sheets("BD enr").Range("a65536").End(xlUp).Row + 1
Else
nuli = Me.cbxChoixDate.ListIndex + 2
End If
If Len(Me.Cbbateau.Value) = 0 Then
mavar = "bateau"
GoTo incomplet
End If
If Len(Me.Cbquai.Value) = 0 Then
mavar = "un quai"
GoTo incomplet
End If
If Len(Me.Cbpoisson.Value) = 0 Then
mavar = "un poisson"
GoTo incomplet
End If
If Me.tbxPoidBrut.Value = 0 Then
mavar = "le poids brut"
GoTo incomplet
End If
'If Me.tbxPartGlace.Value = 0 Then
' mavar = "le pourcentage de glace"
'GoTo incomplet
'End If
If Me.tbxPoidNet.Value = 0 Then
mavar = "le poids net"
GoTo incomplet
End If
With Sheets("BD enr")
.Cells(nuli, 1).Value = Me.DTPicker1.Value
.Cells(nuli, 5).Value = Me.Cbbateau.Value
.Cells(nuli, 6).Value = Me.Cbquai.Value
.Cells(nuli, 7).Value = Me.Cbpoisson.Value
.Cells(nuli, 2).Value = CDbl(Me.tbxPoidBrut)
.Cells(nuli, 3).Value = CDbl(Me.tbxPartGlace) / 100
.Cells(nuli, 4).Value = CDbl(Me.tbxPoidNet)
If Len(.Cells(nuli, 10).Value) = 0 Then .Cells(nuli, 10).Value = varnum
If Len(.Cells(nuli, 9).Value) = 0 Then .Cells(nuli, 9).Value = varcap
nuli = WorksheetFunction.CountA(.Columns(1))
.Range("A2:J" & nuli).Sort Key1:=.Columns(1), Order1:=xlDescending, Header:=xlGuess
End With
miseajour
'Me.cbxChoixDate.ListIndex = -1
MsgBox "La modification est enregistrée."
Exit Sub
incomplet:
MsgBox ("Veuillez saisir " & mavar)
End Sub
Private Sub cmdsuppenrg_Click() 'suppression
derlig = Sheets("BD enr").Range("a65536").End(xlUp).Row
If CheckBox1.Value = True Then
rep = MsgBox("Confirmez! vous allez supprimer touts les enregistrements", vbOKCancel)
If rep = 1 Then Sheets("BD enr").Range("A2:j" & derlig).ClearContents
Exit Sub
End If
nuli = Me.cbxChoixDate.ListIndex + 2 ' la première ligne de données est 2
If Me.cbxChoixDate.ListIndex = -1 Then Exit Sub
rep = MsgBox("Attention! Vous allez supprimer une fiche...Confirmez", vbOKCancel)
If rep = 1 Then Sheets("BD enr").Rows(nuli).Delete
ufConsultation.Hide
End Sub
Private Sub CommandButton1_Click() 'nouvelle pesée
Me.DTPicker1.Enabled = True
Me.DTPicker1.Value = Date
nuli = Sheets("BD enr").Range("a65536").End(xlUp).Row + 1
Sheets("BD enr").Cells(nuli, 1).Value = Me.DTPicker1.Value
Me.Cbbateau.ListIndex = -1
Me.Cbquai.ListIndex = -1
Me.Cbpoisson.ListIndex = -1
Me.tbxPoidBrut.Value = 0
Me.tbxPartGlace.Value = 0
Me.tbxPoidNet.Value = 0
Me.cbxChoixDate.Value = Me.DTPicker1.Value
End Sub
Private Sub UserForm_Initialize()
modi = False
miseajour
modi = True
End Sub
Private Sub cbxChoixDate_Change()
Dim nuli As Integer
If modi = False Then Exit Sub
cbxChoixDate.Value = CDate(cbxChoixDate.Value)
nuli = Me.cbxChoixDate.ListIndex + 2 ' la première ligne de données est 2
If Me.cbxChoixDate.ListIndex = -1 Then nuli = Sheets("BD enr").Range("a65536").End(xlUp).Row
modi = False
Me.DTPicker1.Enabled = True
Me.DTPicker1.Value = CDate(cbxChoixDate.Value)
With Sheets("BD enr")
Me.Cbbateau.Value = .Cells(nuli, 5).Value
Me.Cbquai.Value = .Cells(nuli, 6).Value
Me.Cbpoisson.Value = .Cells(nuli, 7).Value
Me.tbxPoidBrut.Value = Format(.Cells(nuli, 2).Value, "#####.00")
Me.tbxPartGlace.Value = Format(.Cells(nuli, 3).Value * 100, "0.00")
Me.tbxPoidNet.Value = Format(.Cells(nuli, 2).Value * (1 - .Cells(nuli, 3).Value), "#####.00")
End With
modi = True
Me.cmdSortir.SetFocus
End Sub
Private Sub tbxPoidBrut_AfterUpdate()
If modi = False Then Exit Sub
ModiCalcul
End Sub
Private Sub tbxPartGlace_AfterUpdate()
If modi = False Then Exit Sub
ModiCalcul
End Sub
Private Sub cmdSortir_Click()
derlig = Sheets("BD enr").Range("a65536").End(xlUp).Row
For i = 2 To derlig
With Sheets("BD enr")
If .Cells(i, 2).Value = 0 And .Cells(i, 4).Value = 0 Then
.Rows(i).Delete
End If
End With
Next
Unload ufConsultation
End Sub
Sub miseajour()
Me.DTPicker1.Enabled = False
derlig = Sheets("BD bateau").Range("a65536").End(xlUp).Row
For i = 2 To derlig
Me.Cbbateau.AddItem Sheets("BD bateau").Cells(i, 1).Value
Next
Me.Cbbateau.ListIndex = -1
derlig = Sheets("BD quai").Range("a65536").End(xlUp).Row
For i = 2 To derlig
Me.Cbquai.AddItem Sheets("BD quai").Cells(i, 1).Value
Next
Me.Cbquai.ListIndex = -1
derlig = Sheets("BD poisson").Range("a65536").End(xlUp).Row
For i = 2 To derlig
Me.Cbpoisson.AddItem Sheets("BD poisson").Cells(i, 1).Value
Next
Me.Cbpoisson.ListIndex = -1
Me.tbxPoidBrut = 0
Me.tbxPartGlace = 0
Me.tbxPoidNet = 0
'Me.cbxChoixDate.RowSource = bd_enrdate
End Sub
Sub ModiCalcul()
With Sheets("BD enr")
Me.tbxPoidNet = Format(CDbl(Me.tbxPoidBrut) * (1 - CDbl(Me.tbxPartGlace) / 100), "#####.00")
Me.tbxPoidBrut = Format(Me.tbxPoidBrut, "#####.00")
Me.tbxPartGlace = Format(tbxPartGlace, "0.00")
End With
End Sub
Salutation Ghislaine