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
| Function CreerDispos(pDatedeb As Date, pDatefin As Date)
Dim strCritere As String
Dim strSQL As String
Dim dtdebdispo As Date
Dim dtfindispo As Date
Dim oDb As Database
Dim orst1 As Recordset
Dim orst2 As Recordset
Set oDb = CurrentDb
' Vidage de la table
strSQL = "delete * from tbTmpDispo"
oDb.Execute strSQL, dbFailOnError
' Création du recordset des salles
Set orst1 = oDb.OpenRecordset("select * from tblSalle", dbOpenSnapshot)
If orst1.RecordCount > 0 Then
Do While Not orst1.EOF
' Création des dates disponibles
dtdebdispo = pDatedeb
dtfindispo = pDatefin
Set orst2 = oDb.OpenRecordset("select * from tbTmpDispo;", dbOpenDynaset)
strSQL = "(DatesIntersect({0}, {1}, [date_debut], [date_fin]) = True AND libelle_sal = '{2}')"
Do While dtdebdispo <= dtfindispo
orst2.AddNew
orst2!libelle_sal = orst1!libelle_sal
orst2!dtdispo = dtdebdispo
' Recherche des réservations
strCritere = StringFormat(strSQL, DateHeureUS(dtdebdispo), DateHeureUS(dtdebdispo), orst1!libelle_sal)
orst2!flnondispo = Nz(IIf(DCount("*", "tblReservation", strCritere) > 0, True, False), 0)
orst2.Update
dtdebdispo = dtdebdispo + 1
Loop
orst1.MoveNext
Loop
orst2.Close
Set orst2 = Nothing
End If
orst1.Close
Set orst1 = Nothing
Set oDb = Nothing
End Function |
Partager