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
| Function insererStatistique(ByVal typeDonnee As String, _
ByVal province As String, ByVal pays As String, _
ByVal SH As String, ByVal uniteMesure As String, ByVal etat As String) As String
Dim insertion As String
Dim numeroTypeDonnee As String
Dim selection As String
Dim statistique As DAO.Recordset
Dim numeroSeqSH As String
insererSH SH, ""
If (etat <> "") Then
insererEtat etat
End If
numeroSeqSH = getNumeroSH(SH) 'Méthode fait un select, et renvoi la cré primaire
numeroTypeDonnee = getNumeroTypeDonnee(typeDonnee) 'meme chose
selection = "SELECT * FROM STATISTIQUE WHERE numeroTYPEDONNEE = " & numeroTypeDonnee & " AND " & _
"numeroPROVINCE = '" & province & "' AND numeroPAYS = '" & pays & "' AND " & _
" numeroSH = " & numeroSeqSH & " AND uniteDeMesureSTATISTIQUE = '" & uniteMesure & "'"
If (etat <> "") Then
selection = selection & " AND diminutifETAT = '" & validerChaine(etat) & "';"
Else
selection = selection & ";"
End If
Set statistique = CurrentDb.OpenRecordset(selection, dbOpenForwardOnly, dbReadOnly)
If (statistique.EOF) Then
If (etat <> "") Then
insertion = "INSERT INTO STATISTIQUE (numeroTYPEDONNEE, numeroPROVINCE, numeroPAYS " & _
",numeroSH,uniteDeMesureSTATISTIQUE, diminutifETAT) VALUES (" & _
numeroTypeDonnee & ",'" & province & "','" & pays & "'," & numeroSeqSH & _
",'" & uniteMesure & "','" & etat & "');"
Else
insertion = "INSERT INTO STATISTIQUE (numeroTYPEDONNEE, numeroPROVINCE, numeroPAYS " & _
",numeroSH,uniteDeMesureSTATISTIQUE) VALUES (" & _
numeroTypeDonnee & ",'" & province & "','" & pays & "'," & numeroSeqSH & _
",'" & uniteMesure & "');"
End If
CurrentDb.Execute insertion
Set statistique = CurrentDb.OpenRecordset(selection, dbOpenForwardOnly, dbReadOnly)
End If
insererStatistique = statistique("numeroSTATISTIQUE")
End Function |
Partager