Código SQL:
Ver original
Sub CargarDeclaracionesCargo(ByVal vsFxAy AS AxvsFlexLib.AxvsFlexArray, ByVal TipoImpuesto AS String) Dim ImpCn AS NEW ADODB.Connection Dim ImpRd AS NEW ADODB.Recordset Dim Fila, Columna AS INTEGER Dim Importe AS DECIMAL Dim Consulta AS String ImpCn.OPEN("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & RutaRev & ";Persist Security Info=False;Jet OLEDB:DataBase Password=hu9rethu") Consulta = "Select Año, Mes, TipoDeclaracion, TipoImptoCred, Impuesto, ImptoDeclAnt, Actualizacion, Recargos, Total, Compensacion, AcredIVA, " & _ "AcredIDE, PagadoSubsEmp, PagadoEfectivo, FechaPresent, NumOprn, Portal, NumFolioComp, NumOprnAnt, FechaDeclAnt, Observacion From ImptosCargo " & _ "Where TipoImptoCred = '" & TipoImpuesto & "' Group By Mes" ImpRd.OPEN(Consulta, ImpCn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly) ON Error Resume NEXT WITH vsFxAy .ROWS = .FixedRows While NOT ImpRd.EOF .ROWS = .ROWS + 1 .set_TextMatrix(.ROWS - 1, 1, ImpRd.FIELDS("Año").VALUE) .set_TextMatrix(.ROWS - 1, 2, StrConv(MonthName(ImpRd.FIELDS("Mes").VALUE, FALSE), VbStrConv.ProperCase)) .set_TextMatrix(.ROWS - 1, 3, ImpRd.FIELDS("TipoDeclaracion").VALUE) .set_TextMatrix(.ROWS - 1, 4, ImpRd.FIELDS("TipoImptoCred").VALUE) .set_TextMatrix(.ROWS - 1, 5, ImpRd.FIELDS("Impuesto").VALUE) .set_TextMatrix(.ROWS - 1, 6, ImpRd.FIELDS("ImptoDeclAnt").VALUE) .set_TextMatrix(.ROWS - 1, 7, ImpRd.FIELDS("Actualizacion").VALUE) .set_TextMatrix(.ROWS - 1, 8, ImpRd.FIELDS("Recargos").VALUE) .set_TextMatrix(.ROWS - 1, 9, ImpRd.FIELDS("Total").VALUE) .set_TextMatrix(.ROWS - 1, 10, ImpRd.FIELDS("Compensacion").VALUE) .set_TextMatrix(.ROWS - 1, 11, ImpRd.FIELDS("AcredIVA").VALUE) .set_TextMatrix(.ROWS - 1, 12, ImpRd.FIELDS("AcredIDE").VALUE) .set_TextMatrix(.ROWS - 1, 13, ImpRd.FIELDS("PagadoSubsEmp").VALUE) .set_TextMatrix(.ROWS - 1, 14, ImpRd.FIELDS("PagadoEfectivo").VALUE) .set_TextMatrix(.ROWS - 1, 15, ImpRd.FIELDS("FechaPresent").VALUE) .set_TextMatrix(.ROWS - 1, 16, ImpRd.FIELDS("NumOprn").VALUE) .set_TextMatrix(.ROWS - 1, 17, ImpRd.FIELDS("Portal").VALUE) .set_TextMatrix(.ROWS - 1, 18, ImpRd.FIELDS("NumFolioComp").VALUE) .set_TextMatrix(.ROWS - 1, 19, ImpRd.FIELDS("NumOprnAnt").VALUE) .set_TextMatrix(.ROWS - 1, 20, ImpRd.FIELDS("FechaDeclAnt").VALUE) .set_TextMatrix(.ROWS - 1, 21, ImpRd.FIELDS("Observacion").VALUE) CALL AjustarAltoFila(vsFxAy, .ROWS - 1, 260, 21, 60, 4000) ImpRd.MoveNext() END While .ROWS = .ROWS + 1 FOR Columna = 5 TO 14 Importe = 0 FOR Fila = .FixedRows TO .ROWS - 2 Importe = Importe + .get_TextMatrix(Fila, Columna) NEXT Fila .set_TextMatrix(Fila, Columna, Importe) NEXT Columna END WITH CALL AjustarColumnas(vsFxAy, 1, 18) ImpRd.Close() ImpCn.Close() ImpRd = Nothing ImpCn = Nothing Fila = Nothing Columna = Nothing Importe = Nothing END Sub