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
| Private Sub btAjouter_Click()
Dim DB As DAO.Database
Dim rs As DAO.Recordset
On Error GoTo Erreur
Set DB = CurrentDb
If Me.cboClient = 0 Then
Set rs = DB.OpenRecordset("tblCLIENT")
rs.FindFirst "nom_client = " & Forms!F_GestionClient2!nom_client
If rs.NoMatch Then
With rs
.AddNew
!code_client = Me.code_client
!nom_client = Me.nom_client
!nom_contact = Me.nom_contact
!adresse1 = Me.adresse1
!adresse2 = Me.adresse2
!cp_client = Me.cp_client
!ville_client = Me.ville_client
!tel_client = Me.tel_client
!fax_client = Me.fax_client
!email_contact = Me.email_contact
.Update
.Bookmark = .LastModified
Me.code_client = !code_client
End With
Else
MsgBox " Ce client a déjà été enregistré !", vbExclamation, "Attention"
rs.Close
Set rs = Nothing
DB.Close
Set DB = Nothing
Exit Sub
End If
If Me.cboCollab = "" Then
MsgBox "Vous devez affecter un collaborateur à ce client !", vbExclamation, "Attention"
Exit Sub
Else
Set rs = DB.OpenRecordset("tblDOSSIER")
With rs
.AddNew
!num_collab = Me.cboCollab.Column(0)
!code_client = Me.code_client
.Update
.Close
Set rs = Nothing
End With
End If
MsgBox "Le nouveau client a bien été enregistré !", vbInformation, "Info"
End If
Exit Sub
Erreur:
msg = "L'erreur # " & Str(Err.Number) & " a été générée par " & Err.source & Chr(13) & Err.Description
MsgBox msg, , "Erreur", Err.HelpFile, Err.HelpContext
End Sub |
Partager