bonjour,

j'ai un formulaire ou est inseré:
- une Liste_box
- un texte_box
- un bouton de commande.

La texte_box contient la variable date "VJournee". Lorsque j'insere une date en format en format jj/mm/aaa et en cliquant ensuite sur le bouton de commande, des données s'affichent dans la listebox.

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
40
41
42
Option Compare Database
Dim VJournee As Date
Dim txt_ChaineSQL As String
Dim strSQLSELECT As String
Dim strSQLWHERE As String
Dim strSQLGROUPBY As String
Dim strSQLORDERBY As String
 
 
 
 
Private Sub Cmd_envoyer_Click()
VJournee = CDate(Texte_journee) + TimeSerial(5, 0, 0)
 
 
 
With Me.liste_recirculation
.RowSourceType = "Table/Requête"
.ColumnCount = 8 ' nombre de colonne que dois avoir le formulaire intitulé "Listerecirculation"
.BoundColumn = 1 ' la colonne de reference
 
strSQLSELECT = " SELECT [table_Affich-general].DESTINATION, [table_Affich-general].[Chute (format access)], [table_Affich-general].Type, FormatDateTime([DischargeEventTime],2) AS jour, Sum(dbo_vwItemData.RecirculationCount) AS [nbre de colis en recirculation], Round((Sum([RecirculationCount])/Count([ItemID])*100),2) AS taux , FormatDateTime((CVDate((Fix([DischargeEventTime]*24*1)/24/1))),4) AS [tranche horaire], FormatDateTime(CVDate(Fix([DischargeEventTime]*24*6)/24/6),4) AS [10 min]" & _
" FROM dbo_vwItemData INNER JOIN (dbo_vwParts INNER JOIN [table_Affich-general] ON dbo_vwParts.DisplayName = [table_Affich-general].[Chute (format access)]) ON dbo_vwItemData.DischargePartID = dbo_vwParts.ID "
 
strSQLORDERBY = " ORDER BY FormatDateTime([DischargeEventTime],2)ASC "
 
strSQLGROUPBY = " GROUP BY [table_Affich-general].DESTINATION, [table_Affich-general].[Chute (format access)], [table_Affich-general].Type, FormatDateTime([DischargeEventTime],2), FormatDateTime((CVDate((Fix([DischargeEventTime]*24*1)/24/1))),4), FormatDateTime(CVDate(Fix([DischargeEventTime]*24*6)/24/6),4) "
 
strSQLWHERE = " WHERE (dbo_vwItemData.DischargeEventTime) BETWEEN #" & VJournee & "# And  #" & VJournee + 1 & "# "
 
 
txt_ChaineSQL = strSQLSELECT & vbCrLf & _
                strSQLWHERE & vbCrLf & _
                strSQLGROUPBY & vbCrLf & _
                strSQLORDERBY
 
.RowSource = txt_ChaineSQL
.Requery
End With
 
 
End Sub

Mon superieur me demande d'apporter une modification à ce formulaire en inserant non plus une date mais en selectionnant des vacations:

matin : >=([DATE format jj/mm/aaaa])+#05:00:00# Et <=([DATE format jj/mm/aaaa])+#12:30:00#

apres_midi :>([DATE format jj/mm/aaaa])+#12:30:00# Et <=([DATE format jj/mm/aaaa])+#19:30:00#

nuit : >([DATE format jj/mm/aaaa])+#19:30:00# Et <(([DATE format jj/mm/aaaa])+1)+#05:00:00#
L idée serait d'integrer dans le formulaire, une liste déroulante ou je choisirais soit:
-matin
-apres-midi
-nuit
- journée compléte : ( qui correspondrait à la variable Vjournee)

Trés facile à l'ecrire mais trés difficile à le trancrire en vba
C'est pourquoi, je viens vers vous pour une aide..