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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Private Sub Txt_P_AfterUpdate()
Dim C As Range
Dim DL&, n%
'si point en double, passer la recherche pour le 15001
With ThisWorkbook.Worksheets("Base")
DL = .Cells(.Rows.Count, 1).End(xlUp).Row
If Me.Txt_P.Value = "15001" Then
If MsgBox("S'agit il du point de PETRI 1?", vbYesNo) = vbNo Then
Set C = .Range("A1:A" & DL).Find(Txt_P.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
GoTo Pass
End If
End If
Set C = .Range("A1:A" & DL).Find(Txt_P.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
Pass:
If C Is Nothing Then MsgBox "Le numéro de point n'a pas été trouvé!": Set C = Nothing: Me.Txt_P.Value = ""
If Not C Is Nothing Then
n = C.Row
Me.Txt_Nom.Value = .Cells(n, 3).Value
Me.Txt_CAS.Value = .Cells(n, 4).Value
Select Case .Cells(n, 4).Value
Case "Z"
Affiche 'affiche les objets
Me.Cbo_VISA1.Value = VISA
Me.Txt_CHAINE1 = .Cells(n, 2)
Me.Txt_TYPE1 = .Cells(n, 10)
Me.Txt_SAL301 = .Cells(n, 5)
Me.Txt_SAC301 = .Cells(n, 6)
Me.Cbo_VISA1.Value = VISA
If .Cells(n, 10).Value <> "COMBINAISON" And InStr(1, .Cells(n, 10).Text, "GANTS", vbcomparetext) = 0 Then
Me.Txt_GANT1.Value = "": Me.Txt_GANT1.Enabled = False: Me.Txt_GANT1.Visible = False: Label164.Visible = False
Else
Me.Txt_GANT1.Enabled = True: Me.Txt_GANT1.Visible = True: Label164.Visible = True
End If
Me.Txt_CLASSE1.Value = .Cells(n, 9)
Me.Txt_BAT1 = .Cells(n, 11)
Case "HZ": MsgBox "Ce point est un point Hors Z.A.C": Me.Txt_P.Value = "": Exit Sub
Case "E": MsgBox "Ce point est un point EAU": Me.Txt_P.Value = "": Exit Sub
End Select
'si on ajoute lieu
If .Cells(n, 13).Value = "N" Then
Me.Txt_LIEU1.Value = "": Me.Txt_LIEU1.Enabled = False: Me.Txt_LIEU1.Visible = False: Label163.Visible = False
Else
Me.Txt_LIEU1.Enabled = True: Me.Txt_LIEU1.Visible = True: Label163.Visible = True
End If
'si on ajoute air
If .Cells(n, 10).Value <> "IMPACTION D'AIR" Then
Me.Txt_AIR1.Value = "": Me.Txt_AIR1.Enabled = False: Me.Txt_AIR1.Visible = False: Label155.Visible = False
Else
Me.Txt_AIR1.Enabled = True: Me.Txt_AIR1.Visible = True: Label155.Visible = True
End If
'si on debloque les seuils
If .Cells(n, 5).Value = "" And .Cells(n, 6).Value = "" Then
Me.Txt_SAL301.Enabled = True
Me.Txt_SAC301.Enabled = True
End If
Set C = Nothing
End If
End With
Me.Txt_30B1.SetFocus
End Sub |