Contar fechas vencidas
Publicado por David (16 intervenciones) el 28/04/2018 04:20:24
Hola muy buenas, tengo un MSHFlexGrid y lo tengo cargado de una tabla productos que esta en una base de datos de access. me marca en el flex si la fecha de vencimiento del producto es mayor a la actual se me pone en verde si es igual a la fecha actual en amarillo y si es menor en rojo. esta todo bien hasta hay. lo que quiero es poder contar cuantos estan en verde, en amarillo o en rojo y que me lo muestre cada total en un label.
este es el codigo que tengo en ese formulario solo tengo un flex con un boton cerrar y 3 label. Gracias!!
este es el codigo que tengo en ese formulario solo tengo un flex con un boton cerrar y 3 label. Gracias!!
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Option Explicit
Dim Fila As Long
Dim i As Long
Dim j As Long
Private Sub cmdCerrar_Click()
Unload Me
End Sub
Private Sub flex_Click()
Static Modo As Boolean
If (Flex.MouseRow = 0) Then
' Ordena en forma ascendente
If Modo Then
Flex.Col = Flex.MouseCol
Flex.Sort = 2
Modo = False
' Ordena en forma descendente
Else
Flex.Col = Flex.MouseCol
Flex.Sort = 1
Modo = True
End If
End If
End Sub
Private Sub Form_Load()
Productos
Set Flex.DataSource = RsProductos
Busqueda
formato
CargarFlex
End Sub
Private Sub Busqueda()
Dim PlaniVi As Boolean
Dim a As Integer
Set Flex.DataSource = RsProductos
Fila = 0
Do While Not RsProductos.EOF
Fila = Fila + 1
If RsProductos!fecha_vencimiento = Date Then
PintarAmarillo
ElseIf RsProductos!fecha_vencimiento > Date Then
PintarVerde
ElseIf RsProductos!fecha_vencimiento < Date Then
PintarRojo
End If
RsProductos.MoveNext
Loop
End Sub
Sub PintarVerde()
For i = 1 To Flex.Cols - 1
Flex.Row = Fila
Flex.Col = 10
Flex.CellBackColor = &HFF00&
Next
End Sub
Sub PintarAmarillo()
For i = 1 To Flex.Cols - 1
Flex.Row = Fila
Flex.Col = 10
Flex.CellBackColor = &HFFFF&
Next
End Sub
Sub PintarRojo()
For i = 1 To Flex.Cols - 1
Flex.Row = Fila
Flex.Col = 10
Flex.CellBackColor = &HFF&
Next
End Sub
Sub CargarFlex()
With Flex
.ColWidth(0) = 500
.ColWidth(1) = 0
.ColWidth(2) = 0
.ColWidth(3) = 3000
.ColWidth(4) = 3000
.ColWidth(5) = 0
.ColWidth(6) = 0
.ColWidth(7) = 0
.ColWidth(8) = 0
.ColWidth(9) = 0
.ColWidth(10) = 3000
.ColAlignmentFixed(0) = 1
.ColAlignment(0) = 1
.ColAlignmentFixed(9) = 9
.ColAlignment(9) = 9
End With
End Sub
Sub formato()
For i = 1 To Flex.Rows - 1
Flex.TextMatrix(i, 10) = Format(Flex.TextMatrix(i, 10), "dd/mm/yyyy")
Next
End Sub
Valora esta pregunta


0