Filtro de Fechas
Publicado por Andrea (1 intervención) el 04/06/2011 01:46:41
Buenas Noches Amigos,
En VB tengo un MSFLEXGRID llamado grilla, 2 DTPicker un es fecha inicio y el otro fecha final, y ademas un boton llamado btnVer. Mi problema es que de 10 registros que tengo solo me esta filtrando uno. Agradezco quien me pueda ayudar. El siguiente es mi Codigo:
Private Sub btnVer_Click()
f = 1
tot = 0
totg = 0
If dtpFechaInicio.Value > Date Or dtpFechaFin.Value > Date Then
MsgBox "Las Fechas de los Rangos no pueden ser mayores a la fecha actual", vbInformation, "an"
Else
If dtpFechaInicio.Value <= dtpFechaFin.Value Then
grilla.Clear
grilla.TextMatrix(0, 0) = "No. Factura"
grilla.TextMatrix(0, 1) = "Fecha"
grilla.TextMatrix(0, 2) = "Codigo"
grilla.TextMatrix(0, 3) = "Cliente"
adomov.Refresh
adomov.Recordset.Filter = "fecha >= #'" & dtpFechaInicio & "# and fecha <= #'" & dtpFechaFin & "#"
grilla.Rows = adomov.Recordset.RecordCount + 1
If Not adomov.Recordset.EOF And Not adomov.Recordset.BOF Then
adomov.Recordset.MoveFirst
grilla.TextMatrix(f, 0) = adomov.Recordset!nrofactura
grilla.TextMatrix(f, 1) = adomov.Recordset!Fecha
grilla.TextMatrix(f, 2) = adomov.Recordset!codigo
grilla.TextMatrix(f, 3) = adomov.Recordset!vendido_a
Else
MsgBox "No hay Datos para mostrar", vbInformation, "an"
End If
Else
MsgBox "La Fecha de Inicio deber ser menor o igual que la Fecha de Finalización", vbInformation, "an"
End If
End If
End Sub
Private Sub Form_Load()
grilla.TextMatrix(0, 0) = "No. Factura"
grilla.TextMatrix(0, 1) = "Fecha"
grilla.TextMatrix(0, 2) = "Codigo"
grilla.TextMatrix(0, 3) = "Cliente"
dtpFechaInicio.Value = Date
dtpFechaFin.Value = Date
End Sub
En VB tengo un MSFLEXGRID llamado grilla, 2 DTPicker un es fecha inicio y el otro fecha final, y ademas un boton llamado btnVer. Mi problema es que de 10 registros que tengo solo me esta filtrando uno. Agradezco quien me pueda ayudar. El siguiente es mi Codigo:
Private Sub btnVer_Click()
f = 1
tot = 0
totg = 0
If dtpFechaInicio.Value > Date Or dtpFechaFin.Value > Date Then
MsgBox "Las Fechas de los Rangos no pueden ser mayores a la fecha actual", vbInformation, "an"
Else
If dtpFechaInicio.Value <= dtpFechaFin.Value Then
grilla.Clear
grilla.TextMatrix(0, 0) = "No. Factura"
grilla.TextMatrix(0, 1) = "Fecha"
grilla.TextMatrix(0, 2) = "Codigo"
grilla.TextMatrix(0, 3) = "Cliente"
adomov.Refresh
adomov.Recordset.Filter = "fecha >= #'" & dtpFechaInicio & "# and fecha <= #'" & dtpFechaFin & "#"
grilla.Rows = adomov.Recordset.RecordCount + 1
If Not adomov.Recordset.EOF And Not adomov.Recordset.BOF Then
adomov.Recordset.MoveFirst
grilla.TextMatrix(f, 0) = adomov.Recordset!nrofactura
grilla.TextMatrix(f, 1) = adomov.Recordset!Fecha
grilla.TextMatrix(f, 2) = adomov.Recordset!codigo
grilla.TextMatrix(f, 3) = adomov.Recordset!vendido_a
Else
MsgBox "No hay Datos para mostrar", vbInformation, "an"
End If
Else
MsgBox "La Fecha de Inicio deber ser menor o igual que la Fecha de Finalización", vbInformation, "an"
End If
End If
End Sub
Private Sub Form_Load()
grilla.TextMatrix(0, 0) = "No. Factura"
grilla.TextMatrix(0, 1) = "Fecha"
grilla.TextMatrix(0, 2) = "Codigo"
grilla.TextMatrix(0, 3) = "Cliente"
dtpFechaInicio.Value = Date
dtpFechaFin.Value = Date
End Sub
Valora esta pregunta


0