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
| Private Sub valider_Click()
On Error GoTo E_V
Dim Db As DAO.Database
Dim dt As DAO.Recordset
Dim Db1 As DAO.Database
Dim dt1 As DAO.Recordset
Dim Dtcreat As Date
Dim design As String * 70
Dim Design2 As String * 70
Dim Npl As Integer 'N° de plan d'Ensemble ce qui autorise 32.000 plans Ensemble
Dim PROV As String * 10
Dim t, I As Integer
'*******************************************
t = 0
If IsNull([Forms]![Fp_s_Nv_planE]![datecreat]) Then
MsgBox ("Provenance non Renseignée !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![Provenance]) Then
MsgBox ("Provenance non Renseignée !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![Famille]) Then
MsgBox ("Famille non Renseignée !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![produit]) Then
MsgBox ("Produit non Renseigné !!!")
Exit Sub
End If
If [Forms]![Fp_s_Nv_planE]![produit] = "" Then
MsgBox ("Produit non Renseigné !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![Fonction]) Then
MsgBox ("Fonction non Renseignée !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![fonctiond]) Then
MsgBox ("Fonction Détail non Renseignée !!!")
Exit Sub
End If
If ([Forms]![Fp_s_Nv_planE]![fonctiond]) = "" Then
MsgBox ("Fonction Détail non Renseignée !!!")
Exit Sub
End If
If IsNull([Forms]![Fp_s_Nv_planE]![designation]) Then
MsgBox ("Désignation non Renseignée !!!")
Exit Sub
End If
Set Db = DBEngine.Workspaces(0).OpenDatabase(chemin)
Set dt = Db.OpenRecordset("PlansE", DB_OPEN_TABLE)
dt.Index = "PrimaryKey"
dt.MoveLast
Total = dt.RecordCount
If Total > 0 Then
dt.MoveLast
Npl = dt!NplanE + 1
Msg = CodeA & " viens de créer, le N° de plan d'Ensemble N° : " & Npl
Else
Npl = 1
Msg = "N° de plan d'Ensemble N° " & Npl
End If
'MsgBox (msg)
design = Me![designation]
Dtcreat = Me![datecreat]
PROV = Me![Provenance]
'******* Mise a jour de la Table ************
dt.AddNew
dt!Datecreation = Me![datecreat]
'
dt!Provenance = Left$(Me![Provenance], 10)
dt!Famille = Me![Famille]
dt!produit = Me![produit]
dt!designation = Left$(Me![designation], 70)
dt!Fonction = Me![Fonction]
dt!fonctiond = Me![fonctiond]
'
dt!rem = Me![rem]
dt!DatesaisieE = Now
dt!Nature = "ENSEMBLE"
dt!Typep = "NVX"
'
dt!anneecreat = Year(Me![datecreat])
dt!Createur = CodeA
dt!NplanE = Npl
' MsgBox ("zzzzb")
dt.Update
' MsgBox ("zzzzc")
dt.Close
Test = "N"
DoCmd.Close
MsgBox Msg
' il faut aussi creer l'Enregistrement ds la Table "PlansD"
Set Db1 = DBEngine.Workspaces(0).OpenDatabase(chemin)
Set dt1 = Db.OpenRecordset("Plans", DB_OPEN_TABLE)
dt1.AddNew
dt1!NplanE = Npl
dt1!Nplandetail = 0
'************** Mise en forme du N° de plan Total ************
' format NplanTot
' 00000-00"
L = Len(Str$(Npl)) 'Longeur de la chaine de caractere N° plan ensemble
'MsgBox (L)
Npla = Right(Str$(Npl), L - 1) '
L2 = Len(Str$(0)) ' Longueur de la chaine plan de detail
Nplb = Right(Str$(0), L2 - 1)
Pg = Left("00000", 5 - L + 1) + Npla 'chaine N° plan de gauche
pd = Left("00", 2 - L2 + 1) 'chaine N° plan droite
NplanTot = Pg + "-" + pd + Nplb 'chaine de carct N°plan total
'************************************************************
dt1!datesaisie = Now
dt1!datecreat = Dtcreat
dt1!NatureD = "ENSEMBLE"
dt1!NplanTot = NplanTot
Design2 = " "
dt1!LIBELLE = " "
dt1!ANNEECREATD = Year(Dtcreat)
dt1!TYpePD = "NVX"
dt1!createurd = CodeA
dt1!ProvenanceD = PROV
dt1.Update
dt1.Close
Msg = "Je viens de créer également le plan N° : " & NplanTot & " , dans la liste des plans "
MsgBox (Msg)
'--------------- MIS DS LA TABLE 'MOUCHARD' ---------
Set Db = DBEngine.Workspaces(0).OpenDatabase(chemin)
Set dt = Db.OpenRecordset("Mouchard", DB_OPEN_TABLE)
dt.AddNew
dt!NplanTot = Left$(NplanTot, 8)
dt!dateVM = Now
dt!NomP = CodeA
dt!TypeOpe = "C"
dt.Update
dt.Close
z = NBPLANS()
DoCmd.OpenForm "MenusaisieNP"
Exit Sub
E_V:
t = t + 1
If t >= 10 Then
Msg = "BLEME ... " & Error$
MsgBox Msg
DoCmd.OpenForm "MenusaisieNP"
Exit Sub
Else
For I = 1 To (10 * t)
'attente
Next I
Resume
End If
End Sub |
Partager