Ver Mensaje Individual
  #3  
Antiguo 20-03-2019
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 913
Reputación: 22
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Haber si esto te ayuda...
Código Delphi [-]
Sub Contar_Datos()

    Dim cn As Object
    Dim rs As Object
    Dim strSQL  As String
    Dim strCon As String
    Dim strFile As String
    Dim strFromDate, strToDate As String

    strFile = "C:\Users\Desktop\Base.accdb"
    strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFile
    
    strFromDate = InputBox("Desde (mm/dd/yyyy)?", "Rango Fecha")
    strToDate = InputBox("Hasta (mm/dd/yyyy)?", "Rango Fecha")
    
    strSQL = "Select estado, count(Estado) from Consulta where Fechas between #" & strFromDate & "# And #" & strToDate & "#" & _
             " and (Consulta.estado ='DEVOLUCION' or Consulta.Estado='DONACION')" & _
             " group by estado"

    Set cn = CreateObject("ADODB.Connection")
   
    cn.Open strCon

    Set rs = CreateObject("ADODB.RECORDSET")
    rs.activeconnection = cn
    rs.Open strSQL
    
    Hoja1.Range("A1").CopyFromRecordset rs

    rs.Close
    cn.Close
    Set cn = Nothing
           
End Sub

Última edición por Casimiro Notevi fecha: 20-03-2019 a las 22:26:16.
Responder Con Cita