![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
09/08/2010, 10:53
|
![Avatar de a83](http://static.forosdelweb.com/customavatars/avatar122311_12.gif) | | | Fecha de Ingreso: noviembre-2005 Ubicación: Santiago de chile
Mensajes: 637
Antigüedad: 19 años, 2 meses Puntos: 1 | |
Respuesta: urgente consulta complicada Cita:
Iniciado por iislas Por eso mi respuesta, es mejor preguntar por la FECHA COMPLETA que preguntar por año y mes islla mira es es el codigo de VB las fechas las seleciono desde un combo box al Ygual que el producto y el quarter
Código:
Abre_Base
strSql = vbNullString
strAux = vbNullString
strSql = "Select sum(prima_us) as prima_us,mes, year from produ_comercial where "
If cmblinea.ListIndex <> -1 Then
strAux = strAux & "linea = '" & cmblinea.Text & "' "
End If
If cmbperiodo.ListIndex <> -1 Then
If cmbperiodo.ListIndex = 0 Then
strAux = strAux & " and mes in ('12','1','2')"
End If
If cmbperiodo.ListIndex = 1 Then
strAux = strAux & " and mes in ('3','4','5')"
End If
If cmbperiodo.ListIndex = 2 Then
strAux = strAux & " and mes in ('6','7','8')"
End If
If cmbperiodo.ListIndex = 3 Then
strAux = strAux & " and mes in ('9','10','11')"
End If
End If
If cmbfecha1.ListIndex <> -1 Then
strAux = strAux & " and year between " & cmbfecha1.Text & ""
End If
If cmbfecha2.ListIndex <> -1 Then
strAux = strAux & " and " & cmbfecha2.Text & ""
End If
strSql = strSql & strAux
strSql = strSql & " group by mes,year order by mes asc"
lngFila = 0
dblMonto = 0
Call FormatoGrilla
If dbCreaConsultaRapida(strSql, adoRs) Then
Do While Not adoRs.EOF
mfgRet.Col = 1
mfgRet.Row = mfgRet.Rows - 1
If mfgRet.Text <> "" Then
mfgRet.Rows = mfgRet.Rows + 1
End If
mfgRet.Row = mfgRet.Rows - 1
lngFila = lngFila + 1
'mcintprima = mcintprima + 1
If Not IsNull(adoRs![mes]) Then
If (adoRs!mes) = 1 Or (adoRs!mes) = 2 Or (adoRs!mes) = 3 Then
mfgRet.TextMatrix(lngFila, mcintColperiodo) = "1st Quarter"
End If
If (adoRs!mes) = 4 Or (adoRs!mes) = 5 Or (adoRs!mes) = 6 Then
mfgRet.TextMatrix(lngFila, mcintColperiodo) = "2nd Quarter"
End If
If (adoRs!mes) = 7 Or (adoRs!mes) = 8 Or (adoRs!mes) = 9 Then
mfgRet.TextMatrix(lngFila, mcintColperiodo) = "3rd Quarter"
End If
If (adoRs!mes) = 10 Or (adoRs!mes) = 11 Or (adoRs!mes) = 12 Then
mfgRet.TextMatrix(lngFila, mcintColperiodo) = "4th Quarter"
End If
End If
If Not IsNull(adoRs![Year]) Then
mfgRet.TextMatrix(lngFila, mcintColfecha) = adoRs!Year
End If
If Not IsNull(adoRs![prima_us]) Then
mfgRet.TextMatrix(lngFila, mcintprima) = Format(adoRs!prima_us, "#,###.00")
End If
If adoRs![prima_us] Then
dblMonto = dblMonto + adoRs![prima_us]
End If
adoRs.MoveNext
Loop
adoRs.Close
Set adoRs = Nothing
'Me.lblTotalPrima = prima_us
txtPesos.Text = Format(CLng(dblMonto), "#,##0")
End If
End Sub
te das cuenta que tengo que iniciciar el año en diciembre que quiero decri que cuado le diaga buscame desde el 2009 al 2009 el sepa que el año se inicia el 2008 diciembre |