bonjour Philippe
Regarde ce code que j'avais fait il y a quelques temps déjà. Je pense que cela peut t'aider. Je récupérais 1 date de début et une date de fin que je mettais en forme pour les utiliser ensuite dans ma requête.
____________________________________________________________
QDateDeb = InputBox("Quelle est la date de début de la période ?", "Période de remplacement.")
If IsDate(QDateDeb) Then
DateDeb = QDateDeb
monjour = Format(Day(DateDeb), "00")
monmois = Format(Month(DateDeb), "00")
monannee = Format(Year(DateDeb), "0000")
datedeb1 = monannee & "-" & monmois & "-" & monjour
ElseIf QDateDeb = "" Then
Exit Sub
Else: MsgBox "Vous devez rentrer une date sous le format jj/mm/aa."
GoTo ErDateDeb
End If
ErDateFin:
QDateFin = InputBox("Quelle est la date de fin de la période ?", "Période de remplacement.")
If IsDate(QDateFin) Then
DateFin = QDateFin
monjour = Format(Day(DateFin), "00")
monmois = Format(Month(DateFin), "00")
monannee = Format(Year(DateFin), "00")
datefin1 = monannee & "-" & monmois & "-" & monjour
ElseIf QDateFin = "" Then
Exit Sub
Else: MsgBox "Vous devez rentrer une date sous le format jj/mm/aa."
GoTo ErDateFin
End If
nbreligne = Range("A2").CurrentRegion.Rows.Count
Range(Cells(3, 1), Cells(nbreligne, 9)).Select
Selection.ClearContents
Range("A2").Select
With Selection.QueryTable
.Connection = _
"ODBC;DRIVER={Hyper File};ANA=J:\GESPERS\HSF\GESPERS.WDD;REP=J:\GESPERS\;ANA=J:\GESPERS\HSF\GESPERS.WDD;"
.CommandText = Array( _
"SELECT REMPLACE.NOMREMPLAC, REMPLACE.PREREMPLAC, REMPLACE.NOMTITULAI, REMPLACE.PRETITULAI, REMPLACE.TYPEABSENC, REMPLACE.DEBREMPL, REMPLACE.FINREMPL" & Chr(13) & "" & Chr(10) & "FROM J:\GESPERS\HSF\GESPERS.WDD~REMPLACE REMPLACE" & Chr(13) & "" _
, "" & Chr(10) & "WHERE (REMPLACE.FINREMPL>{d " & Chr(39) & datedeb1 & Chr(39) & "}) AND (REMPLACE.DEBREMPL<{d " & Chr(39) & datefin1 & Chr(39) & "})")
.Refresh BackgroundQuery:=False
End With
____________________________________________________________
Tiens moi au courant et bon courage car je me rappelle que j'en avais du temps à tout mettre en fonction.
Pascal