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
|
Public Function New_Société(Nom_Société As String) As Boolean
Dim Rs0 As DAO.Recordset
Set Rs0 = CurrentDb.OpenRecordset("Select * from T_Société where Nom_Société = """ & Nom_Société & """ ;")
If Rs0.AbsolutePosition = -1 Then
'Création de la société
DoCmd.RunSQL ("Insert into T_Société(Nom_Société) values('" & Nom_Société & "') ;")
MsgBox "Société """ & Nom_Société & """ créée !"
New_Société = True
Else
MsgBox "La société """ & Nom_Société & """ existe déjà !"
New_Société = False
End If
End Function
Public Function New_Agence(Nom_Agence As String, Num_Département As String, Ville As String, ID_Société As Integer) As Boolean
Dim Rs0 As DAO.Recordset
Set Rs0 = CurrentDb.OpenRecordset("Select * from T_Agence where Nom_Agence = """ & Nom_Agence & """ and ID_Société = " & ID_Société & " ;")
'Vérifie que l'agence n'existe pas déjà
If Rs0.AbsolutePosition = -1 Then
'Création de l'agence
DoCmd.RunSQL ("Insert into T_Agence(Nom_Agence, Département, Ville, ID_Société) values('" & Nom_Agence & "', '" & Num_Département & "', '" & Ville & "', " & ID_Société & ") ;")
MsgBox "Agence """ & Nom_Agence & """ créée !"
New_Agence = True
Else
MsgBox "L'agence """ & Nom_Agence & """ existe déjà pour cette société !"
New_Agence = False
End If
End Function
Public Function Nouveau_Contact(Prénom As String, NOM As String, MAIL As String, ID_Agence As Integer, Optional Tel As String, Optional FAX As String) As Boolean
'********* La fonction renvoie "True" si la création s'est bien effectuée ****************'
Dim Rs0 As DAO.Recordset
Set Rs0 = CurrentDb.OpenRecordset("Select * from T_Contact where Nom_Contact = """ & NOM & """ and Prénom_Contact = """ & Prénom & """ and ID_Agence = " & ID_Agence & " ;")
'Vérifie que le contact n'existe pas déjà
If Rs0.AbsolutePosition = -1 Then
'Création du contact
DoCmd.RunSQL ("Insert into T_Contact(Nom_Contact, Prénom_Contact, Tel_Contact, Fax_Contact, Mail_Contact, Id_Agence) values('" & NOM & "', '" & Prénom & "', '" & Tel & "', '" & FAX & "', '" & MAIL & "', " & ID_Agence & ") ;")
MsgBox "Contact """ & NOM & """ créée !"
Nouveau_Contact = True
Else
MsgBox "Le contact """ & NOM & " " & Prénom & """ existe déjà !"
Nouveau_Contact = False
End If
End Function |
Partager