Bonjour,

Dans un module qui commence par Est-il possible d'utiliser ce code dans une requête ?
Si oui comment inscrire ceci dans un nouveau champ ?

Par exemple :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 Public Function NbOpenDay(dtDeb As Date, dtFin As Date) As Integer
    ' Calculer le nombre de jours ouvrables entre deux dates
    ' Utilise la fonction JourFérié(dtDate As Date)
 
        Dim dblDateDeb As Double
        Dim dblDateFin As Double
        Dim DateCourante As Date
        Dim resultat As Integer
 
        If IsNull(dtDeb) Or IsNull(dtFin) _
            Or IsEmpty(dtDeb) Or IsEmpty(dtFin) Then
                NbOpenDay = 0
                Exit Function
        ElseIf Not IsDate(dtDeb) Or Not IsDate(dtFin) Then
                NbOpenDay = 0
                Exit Function
        ElseIf dtDeb > dtFin Then
                Dim dhTemp As Date
                dhTemp = dtDeb
                dtDeb = dtFin
                dtFin = dhTemp
        End If
 
        dblDateDeb = CDbl(dtDeb)
        dblDateFin = CDbl(dtFin)
 
        Do Until dblDateDeb > dblDateFin
            DateCourante = CDate(dblDateDeb)
            If WeekDay(DateCourante) <> 1 And _
                WeekDay(DateCourante) <> 7 And _
                JourFérié(DateCourante) = False Then
                    resultat = resultat + 1
            End If
            dblDateDeb = dblDateDeb + 1
        Loop
 
        NbOpenDay = resultat
 
    End Function
Merci d'avance
Cordialement