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
| Option Compare Database
Option Explicit
Public Sub NbreVisites()
Dim rs As DAO.Recordset
Dim i As Integer
Dim sSql As String
DoCmd.SetWarnings False
'Vidanger tResult (données de l'exécution précédente)
DoCmd.RunSQL "DELETE id FROM tResultDetail;"
'Créer un recordset de la table MEDICAL
Set rs = CurrentDb.OpenRecordset("MEDICAL")
'On lit enregistrement après enregistrement
Do Until rs.EOF
'On explore chaque champ
For i = 0 To rs.Fields.Count - 1
If IsDate(rs(i)) Then 's'il contient une date
'on crée un enregistrement dans la table tResultDetail
sSql = "INSERT INTO tResultDetail ( Patient, Datej ) SELECT """ _
& rs("codep") & """ AS Expr1, #" & Format(rs(i), "mm/dd/yy") & "# AS Expr2;"
DoCmd.RunSQL sSql
End If
Next i
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
DoCmd.SetWarnings True
'On affiche la récap par année
DoCmd.OpenQuery "rSynthese"
End Sub |
Partager