Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/09/2008, 13:14
usasisra
 
Fecha de Ingreso: septiembre-2008
Mensajes: 2
Antigüedad: 15 años, 7 meses
Puntos: 0
Consulta de fechas con restricciones

Estoy haciendo un reporte de fechas en visual y tengo un Dtepicker1, Dtepicker2, boton de busqueda(cmdprint), y un command(cmdall) (Que muestra todos los registros), un modulo y un Mshflexgrid1
Y tengo 2 combobox
En combobox1 tengo la opción ingresos y egresos
En combobox2 tengo las opciones Inscripcion, reinscripción, colegiatura,Otros pagos
Mi base de datos se llama ALTAS y la tabla PAGOS y es la que quiero utilisar para sacar mis consultas
Y LO QUE QUIERO ES QUE SI SELECCIONAN DEL COMBOBOX INGRESOS O ADEUDOS.
SOLO MUESTRE LOS INGRESOS O LOS ADEUDOS DEL LA OPCION QUE SE SELECCIONO EN EL COMBOBOX 2.
Ejemplo(colegiatura, adeudo) o colegiatura(ingresos)
Las opciones de colegiatura, inscripcion, reinscripcion las tengo en mi base de datos como true1 o false0
Y ES QUE AL HACER LA CONSULTA CON LA FECHA ME MUESTRA INGRESOS Y ADEUDOS Y LO QUE QUIERO ES QUE ME MUESTRE SI YA PAGARON O TODAVIA TIENEN UN ADEUDO.
Y este es el codigo
Option Explicit

Private Sub cmdall_Click()

query ("select * from ALTAS")

If deparam.rscmdparam.State = adStateOpen Then
deparam.rscmdparam.Close
End If

deparam.cmdparam CDate("21/08/1994"), CDate("01/01/2100")

Load rptparam
rptparam.Show
End Sub
Private Sub cmdprint_Click()
On Error GoTo trap

If deparam.rscmdparam.State = adStateOpen Then
deparam.rscmdparam.Close
End If
deparam.cmdparam DTPicker1.Value, DTPicker2.Value
Load rptparam
rptparam.Show
trap:
Exit Sub
End Sub

Private Sub DTPicker1_Change()
query ("select * from PAGOS where Fecha de pago between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#")
End Sub
Private Sub DTPicker2_Change()
query ("select * from PAGOS where Fecha de pago between #" & DTPicker1.Value & "# and #" & DTPicker2.Value & "#")
End Sub
Private Sub Form_Activate()
query ("select * from PAGOS")
End Sub
Private Sub Form_Load()
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
Set cn = New Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;User ID=Admin;Data Source=" & App.Path & "\ALTAS.mdb;Mode=Share Deny None;Extended Properties=';COUNTRY=0;CP=1252;LANGID=0x0409';Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB atabase Password='';Jet OLEDB:Global Partial Bulk Ops=2"
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
cn.Close
End Sub
Private Sub query(sql1 As String)
Set rs = New Recordset
rs.CursorLocation = adUseClient
rs.Open sql1, cn, adOpenForwardOnly, adLockReadOnly
Set MSHFlexGrid1.DataSource = rs
MSHFlexGrid1.Refresh
End Sub
En la consulta SQL TENGO SELECT * FROM PAGOS WHERE (`Fecha de pago` BETWEEN ? AND ?)

Si alguien tiene una respuesta se los agradeceria o alguna otra forma de hacer el reporte.