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
|
Option Compare Database
Private Function Trt_Existe(Code_Oaci As String) As Boolean
Dim RS As Recordset
On Error GoTo Err_Num
WCode_OACI = Ajout_Quote(Trim(UCase(Code_Oaci)))
WRequete = "Select * from COM where COM.C_OACI = " & WCode_OACI
Set RS = CurrentDb.OpenRecordset(WRequete, 2)
With RS
.OpenRecordset
If .RecordCount > 0 Then
Trt_Existe = True
End If
.Close
End With
Sortie_Num:
Set RS = Nothing
Exit Function
Err_Num:
Trt_Existe = False
Resume Sortie_Num
End Function
Private Sub B_Annulation_Click()
Call Form_Load
B_Annulation.Visible = False
B_Validation.Visible = False
End Sub
Private Sub B_Validation_Click()
If MsgBox("Enregistrement de la saisie en cours ?", vbYesNo + vbQuestion, "Validation ?") = vbYes Then
' Vérifications de la saisie
' INSERT de la saisie
' préparation à la saisie d'un nouvel enregistrement
WOACI = Ajout_Quote(Trim(UCase(C_OACI)))
WADP = Ajout_Quote(Trim(UCase(C_ADP)))
WEXCOD = Ajout_Quote(Trim(UCase(C_EXCOD)))
WLIB = Ajout_Quote(Trim(UCase(C_LIB)))
WLAND = Ajout_Quote(Trim(UCase(C_LAND)))
WInsert = "insert into COM values (" & WOACI & "," & WADP & "," & WEXCOD & "," & WLIB & "," & WLAND & ")"
DoCmd.RunSQL (WInsert)
Call B_AjouterCompagnie_Click
Else
MsgBox "Enregistrement annulé."
C_OACI.SetFocus
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(C_OACI) Then
If Trt_Existe(C_OACI.Value) Then
MsgBox "Ce code OACI existe déjà dans la table."
Cancel = True
C_OACI.SetFocus
Else
Cancel = False
End If
Else
MsgBox ("Le champ 'Code OACI' ne peut pas être vide.")
C_OACI.SetFocus
End If
End Sub
Private Sub Form_AfterInsert()
MsgBox "Ajout effectué."
C_OACI.Locked = True
C_ADP.Locked = True
C_EXCOD.Locked = True
C_LAND.Locked = True
C_LIB.Locked = True
C_Compagnie.Value = ""
C_Compagnie.Locked = False
C_Compagnie.SetFocus
B_Validation.Visible = False
B_Annulation.Visible = False
Me.AllowAdditions = False
End Sub
Private Sub C_Compagnie_AfterUpdate()
' Rechercher l'enregistrement correspondant au contrôle.
Dim RS As Object
Set RS = Me.Recordset.Clone
RS.FindFirst "[C_OACI] = '" & Me![C_Compagnie] & "'"
If Not RS.EOF Then Me.Bookmark = RS.Bookmark
End Sub
Private Sub B_AjouterCompagnie_Click()
On Error GoTo Err_B_AjouterCompagnie_Click
' il faut déverrouiller tous les champs
C_OACI.Locked = False
C_ADP.Locked = False
C_EXCOD.Locked = False
C_LAND.Locked = False
C_LIB.Locked = False
C_Compagnie.Value = ""
C_Compagnie.Locked = True
C_OACI.SetFocus
B_Validation.Visible = True
B_Annulation.Visible = True
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Exit_B_AjouterCompagnie_Click:
Exit Sub
Err_B_AjouterCompagnie_Click:
MsgBox Err.Description
Resume Exit_B_AjouterCompagnie_Click
End Sub
Private Sub B_QuitterCompagnie_Click()
On Error GoTo Err_B_QuitterCompagnie_Click
If MsgBox("Annuler l'opération en cours et quitter le formulaire ?", vbQuestion + vbYesNo, "Sorite ?") = vbYes Then
DoCmd.Close
End If
Exit_B_QuitterCompagnie_Click:
Exit Sub
Err_B_QuitterCompagnie_Click:
MsgBox Err.Description
Resume Exit_B_QuitterCompagnie_Click
End Sub
Private Sub B_SupprimerCompagnie_Click()
On Error GoTo Err_B_SupprimerCompagnie_Click
If MsgBox("Suppression de la compagnie en cours ?", vbQuestion + vbYesNo, "Suppression ?") = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
Exit_B_SupprimerCompagnie_Click:
Exit Sub
Err_B_SupprimerCompagnie_Click:
MsgBox Err.Description
Resume Exit_B_SupprimerCompagnie_Click
End Sub
Private Sub Form_Load()
DoCmd.SetWarnings False
Me.AllowAdditions = False
C_OACI.Locked = True
C_ADP.Locked = True
C_EXCOD.Locked = True
C_LAND.Locked = True
C_LIB.Locked = True
C_Compagnie.Value = ""
C_Compagnie.Locked = False
C_Compagnie.SetFocus
End Sub
Private Sub Form_Unload(Cancel As Integer)
DoCmd.SetWarnings True
End Sub
Private Function Ajout_Quote(P_Valeur)
WValeur = "'" & P_Valeur & "'"
Ajout_Quote = WValeur
End Function |
Partager