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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
| Private Sub clnomsociete_Change()
Dim c As Object ' Variable résultat de la recherche
Dim iLignes As Integer
' Recherche du nombre de ligne de la plage de données
iLignes = Application.WorksheetFunction.CountA(Range("Feuil1!A:A"))
' La recherche s'effectue dans la plage A2:Axx de la feuille Feuil1
With Range("Feuil1!A2:A" & iLignes)
Set c = .Find(What:=Trim(clnomsociete), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
On Error Resume Next
' Le textBox txtNomreçoit la valeur contenue dans la colonne B de la ligne correspondant à la référence cherchée
Me.adresse = c.Offset(0, 1)
Me.Adresse1 = c.Offset(0, 2)
Me.ComboBoxcp = c.Offset(0, 3)
Me.ComboBoxville = c.Offset(0, 4)
End With
End Sub
Private Sub UserForm_Initialize()
Sheets("clients").Activate
For i = 2 To 1000
Me.clnomsociete.AddItem Range("A" & i).Value
Next
Sheets("liste de choix").Activate
For i = 1 To 42008
Me.ComboBoxcp.AddItem Range("B" & i).Value
Me.ComboBoxville.AddItem Range("A" & i).Value
Next
For i = 1 To 3
Me.cltypetravail.AddItem Range("D" & i).Value
Next
For i = 1 To 9
Me.clviaentreprise.AddItem Range("J" & i).Value
Next
For i = 1 To 2
Me.Combotitre.AddItem Range("F" & i).Value
Next
For i = 1 To 9
Me.ComboBox1.AddItem Range("H" & i).Value
Next
For i = 1 To 2
Me.ComboBox2.AddItem Range("I" & i).Value
Next
'Userform en plein écran
Me.Width = ScreenWidth * PointsPerPixel - 3
Me.Height = ScreenHeight * PointsPerPixel
'Rapport d'agrandissement de la form/taille écran en points
Dim RW As Single, RH As Single
RW = ScreenWidth * PointsPerPixel / Me.Width
RH = ScreenHeight * PointsPerPixel / Me.Height
With FrmClient
.StartUpPosition = 3
.Width = Application.Width
.Height = Application.Height
.Left = 0
.Top = 0
End With
Dim iLignes As Integer
iLignes = Application.WorksheetFunction.CountA(Range("Feuil1!A:A"))
Me.clnomsociete.RowSource = "=Feuil1!$A$2:$A" & iLignes
End Sub
Private Sub clnomsociete_AfterUpdate()
If ModifClient = False Then Exit Sub
Dim NoRetModif As Boolean
NoRetModif = False
'traiter la modif nom client
ModClient SélN, txtpC.Text, cmbnC.Text, NoRetModif
'on actualise la variable donnant le nom en cours ou on remet le nom de départ si pas de retour
If NoRetModif = True Then cmbnC.Text = SélN Else SélN = cmbnC.Text
End Sub
Private Sub ComboBoxcp_Change()
ComboBoxville.ListIndex = ComboBoxcp.ListIndex
ComboBoxville.Value = ComboBoxville.List(ComboBoxville.ListIndex)
End Sub
Private Sub ComboBoxville_Change()
ComboBoxcp.ListIndex = ComboBoxville.ListIndex
ComboBoxcp.Value = ComboBoxcp.List(ComboBoxcp.ListIndex)
End Sub
Private Sub CommandButton1_Click() 'spécificités
Me.Hide
Op = "spécificités"
frmspecific.Show
End Sub
Private Sub CommandButton2_Click()
Me.Hide
Op = " retour menu"
frmmenu.Show
End Sub
Private Sub CommandButton3_Click()
'EntDim d As DonnéesClient, m As VbMsgBoxResult, i As Integer
'Entrée client
d.Nom = clnomsociete.Text
d.Ville = txtpC.Text
If d.Nom = "" Then
If Op = "Saisie" Then
MsgBox "Il faut rentrer le nom du client!", vbCritical, "Entrée non valable": cmbnC.SetFocus
Else
MsgBox "Sélectionner un client!", vbCritical, "Entrée non valable": cmbnC.SetFocus
ModifClient = False 'au cas où...
End If
Exit Sub
End If
If d.Ville = "" And d.Nom <> "" Then
MsgBox "Il faut rentrer une ville pour le client!", vbExclamation, "Manque Ville"
txtpC.SetFocus
ModifClient = False 'au cas où...
Exit Sub
End If
If cmbnC.Text <> "" And txtpC.Text <> "" Then d = fd(cmbnC.Text, txtpC.Text) 'indique si client existe
d.Nom = Trim(cmbnC.Text) 'ajout 9F_5 pour sup blancs g et d du nom
d.Prénom = Trim(txtpC.Text) 'ajout 9F_5 pour sup blancs g et d du prénom
d.ad = txtaD.Text
d.Ville = txtVi.Text
d.Code = txtCo.Text
d.Pays = txtPays.Text
d.Tél = txtTél.Text
d.Port = txtPort.Text
d.eMail = txtMail.Text
EntréeClient d, CelNC
cmbnC.RowSource = "ChampNPC" 'on réactualise la liste clients au cas où
'Entrée Travail
Dim dW As DonnéesW
m = 0
If Op = "Saisie" Then
If txtType.Text = "" And cmbW.ListCount = 0 Then
m = MsgBox("Vous n'avez pas rentré de travail pour ce client" & vbCr & _
"Voulez-vous en rentrer un maintenant?", vbExclamation + vbYesNo, "PAS DE TYPE DE TRAVAIL")
If m = vbYes Then Exit Sub Else GoTo Fin
End If
If txtNumC = "" Then
MsgBox "Il faut entrer au moins un n° Rf1!", vbExclamation, "Entrée incomplète"
txtNumC.SetFocus
Exit Sub
End If
If txtPrix = "" Then m = MsgBox("Confirmez-vous l'absence de prix?", vbYesNo, "PAS DE PRIX!")
If m = vbNo Then txtPrix.SetFocus: Exit Sub
Else
If ModifClient = True Then
MsgBox "Le nom client a été modifié", vbInformation, "": ModifClient = False: Exit Sub
End If
End If
dW.TypeW = NomW
dW.DiversW = txtDiv
dW.NumC = txtNumCAn & txtNumC
If txtNumP <> "" Then dW.NumP = txtNumPAn & txtNumP Else dW.NumP = ""
If txtNumB <> "" Then dW.NumB = txtNumBAn & txtNumB Else dW.NumB = ""
If txtPrix <> "" Then dW.PrixTTC = txtPrix Else dW.PrixTTC = 0
If txtTVA <> "" Then dW.TVA = txtTVA Else dW.TVA = 0
If txtAcompte <> "" Then dW.Acompte = txtAcompte Else dW.Acompte = 0
dW.DateW = txtDate
If optO Then dW.Cmd = "oui" Else dW.Cmd = "non"
EntréeTravail d, dW
Exit Sub
Fin:
MsgBox "Saisie effectuée sans travail affecté!", vbExclamation, ""
End Sub
Private Sub CommandButton4_Click() 'bons
Me.Hide
Op = "bons"
frmbons.Show
End Sub
Private Sub Commandvalider_Click()
Dim iLigne As Integer
Sheets("clients").Activate
Societeconverti = Application.WorksheetFunction.Proper(Me.clnomsociete.Text)
Villeconverti = Application.WorksheetFunction.Proper(Me.ComboBoxville.Text)
Contactconverti = Application.WorksheetFunction.Proper(Me.Combocontact.Text)
iLigne = LigneRechercher("Ma référence")
Range("A" & iLigne) = clnomsociete.Value
Range("B" & iLigne) = adresse.Value
Range("C" & iLigne) = adress1.Value
Range("D" & iLigne) = ComboBoxcp.Value
Range("E" & iLigne) = ComboBoxville.Value
Range("F" & iLigne) = Combotitre.Value
Range("G" & iLigne) = Combocontact.Value
Range("H" & iLigne) = TextBoxtel.Value
Range("I" & iLigne) = TextBoxport.Value
Range("J" & iLigne) = TextBoxfax.Value
Range("K" & iLigne) = TextBoxmail.Value
Range("L" & iLigne) = TextBoxsiteweb.Value
Unload Me
End Sub
Function LigneRechercher(sTexteCherche As String) As Integer
Dim c As Object
With Worksheets(1).Range("a1:a65536")
Set c = .Find(sTexteCherche, LookIn:=xlValues)
If Not c Is Nothing Then
LigneRechercher = c.Row
Else
LigneRechercher = Range("A65536").End(xlUp).Offset(1, 0).Row
End If
End With
End Function |