Jump to content
Fórum Script Brasil
  • 0

Type Mismatch


jerry-sc

Question

Pessoal, bom dia!

Tenho esse código abaixo, que faz gerar um relatório.

Acontece que, quando eu passo os parâmetro de data (data inicial, data final) com o ano de 2012 ele retorna type mismatch.

Quando eu passo o mesmo parâmetro com o intervalo de 2011 funciona normal.

Alguém têm idéia do que pode ser? Vou deixar em negrito e sublinhado em qual linha ele reclama a incompatibilidade de dados.

----

Dim QPARCELAS As Object
Dim TOTAL As Currency
Dim VALOR As Currency
Dim SALDOMOEDA As Currency
Dim MORA As Currency
Dim MULTA As Integer
Dim VALORMOEDA As Currency
Dim VALCOT As Currency
Dim DATAMULTA As Date
Dim DATAVENCIMENTO As Date
Dim VALORESBAIXADOS As Currency
Dim CODMOEDA As Integer
Dim DESCONTO As Currency
Dim ABATIMENTOS As Currency
Dim ACRESCIMOS As Currency
Dim TOTALACRESCIMOS As Currency
Dim TOTALDESCONTOS As Currency
Dim OBJ As Object
Dim DATAINICIAL As Date
Dim DATAFINAL As Date
Dim DATAPOSICAO As Date
Dim EPOSICAO As Boolean
Dim I As Integer
Dim D As String

Public Sub REPORT_BeforePrint(PrintReport As Boolean)

    Set QPARCELAS = REPORT.QueryByName("FN_PARCELAS")
    Set OBJ = CreateBennerObject("CorpComum.Generico")

End Sub

Public Sub REPORT_DestroyData()

    Set QPARCELAS = Nothing
    Set OBJ = Nothing
    TOTAL = 0
    TOTALACRESCIMOS = 0
    TOTALDESCONTOS = 0
    
End Sub
Dim DataForm As String

Public Sub REPORT_OnMacroValue(ByVal Name As String, ResultValue As Variant)

    Select Case Name

        Case "VALORATUAL"

              If QPARCELAS.FieldByName("VALORMOEDA").IsNull Or QPARCELAS.FieldByName("VALORMOEDA").AsFloat = 0 Then
                 VALOR = QPARCELAS.FieldByName("VALOR").AsFloat
                 VALORESBAIXADOS = QPARCELAS.FieldByName("VALORESBAIXADOS").AsFloat
                 VALCOT = 1
                 SALDOMOEDA = VALOR - VALORESBAIXADOS
              Else
                 VALORMOEDA = QPARCELAS.FieldByName("VALORMOEDA").AsFloat
                 VALOR = VALORMOEDA
                 VALORESBAIXADOS = QPARCELAS.FieldByName("VALORESBAIXADOSMOEDA").AsFloat
                 CODMOEDA = QPARCELAS.FieldByName("MOEDAHANDLE").AsInteger
                 VALCOT = OBJ.CotacaoMoeda(CurrentSystem,CODMOEDA,Date)
                 SALDOMOEDA = VALOR - VALORESBAIXADOS
              End If


              SALDOMOEDA = SALDOMOEDA * VALCOT
              TOTAL = SALDOMOEDA
            

              If QPARCELAS.FieldByName("DATAVENCIMENTO").IsNull Then
                 DATAVENCIMENTO = 0
              Else
                 DATAVENCIMENTO = QPARCELAS.FieldByName("DATAVENCIMENTO").Value
              End If


              If QPARCELAS.FieldByName("DATALIMITEDESCONTOCONDICIONAL").IsNull Then
                 DESCONTO = 0
              Else
                 datadesconto = QPARCELAS.FieldByName("DATALIMITEDESCONTOCONDICIONAL").Value
                 If DateDiff("d",datadesconto,Date) > 0 Then
                    DESCONTO = 0
                 Else
                    DESCONTO = QPARCELAS.FieldByName("DESCONTOCONDICIONAL").Value
                 End If
              End If


              If QPARCELAS.FieldByName("DATALIMITEMULTA").IsNull Then
                 DATAMULTA = 0
              Else
                 DATAMULTA = QPARCELAS.FieldByName("DATALIMITEMULTA").Value
              End If


                 MULTA = QPARCELAS.FieldByName("PERCENTUALMULTA").AsInteger
                 MORA = QPARCELAS.FieldByName("MORADIARIA").AsFloat
        

              If DateDiff("d",DATAVENCIMENTO,Date) > 0 Then
                 If DateDiff("d",DATAMULTA,Date) > 0 Then
                    TOTAL = TOTAL + (DateDiff("d",DATAVENCIMENTO,Date)*MORA)+(TOTAL*(MULTA/100)) 
                 Else
                    TOTAL = TOTAL + (DateDiff("d",DATAVENCIMENTO,Date)*MORA) 
                 End If
              End If
        

              If QPARCELAS.FieldByName("ACRESCIMOS").IsNull Then
                 ACRESCIMOS = 0
              Else
                 ACRESCIMOS = QPARCELAS.FieldByName("ACRESCIMOS").Value
              End If
        

              If QPARCELAS.FieldByName("ABATIMENTOS").IsNull Then
                 ABATIMENTOS = 0
              Else
                 ABATIMENTOS = QPARCELAS.FieldByName("ABATIMENTOS").Value
              End If

              TOTAL = TOTAL + ACRESCIMOS

              TOTALACRESCIMOS = TOTAL - SALDOMOEDA

              TOTAL = TOTAL - DESCONTO - ABATIMENTOS

              TOTALDESCONTOS = DESCONTO + ABATIMENTOS

                ResultValue = SALDOMOEDA


              Case "ACRESCIMOS"
                    ResultValue = TOTALACRESCIMOS


               Case "DESCONTOS"
                    ResultValue = TOTALDESCONTOS


              Case "TOTALGERAL"
                    ResultValue = TOTAL


                Case "DATAINICIAL"
                    If EPOSICAO = True Then
                       ResultValue = ""
                    Else
                          ResultValue = "Data Inicial: "+CStr(Format(DATAINICIAL,"dd/mm/yyyy"))
                    End If


              Case "DATAFINAL"
                    If EPOSICAO = True Then
                         ResultValue = "Data Posição: "+CStr(Format(DATAPOSICAO,"dd/mm/yyyy"))
                    Else
                         ResultValue = "Dafa Final: "+CStr(Format(DATAFINAL,"dd/mm/yyyy"))
                    End If

        End Select

End Sub
Public Sub REPORT_OnPrepareReport(CanPrint As Boolean)

    REPORT.ShowFilter = False

End Sub

Public Sub REPORT_SetParams(ByVal aParams As String)

    EPOSICAO = False

    If Mid(ShortHint(aParams),1,8) = "Database" Then
       EPOSICAO = True
       D = ShortHint(aParams)
       I = StrPos("=",D)
       DATAPOSICAO = CDate(Mid(D,I+1,Len(D)-I))
    Else
       EPOSICAO = False
       D = ShortHint(aParams)
       I = StrPos("=",D)
       DATAINICIAL = CDate(Mid(D,I+1,Len(D)-I))

       I = StrPos("DataFinal=",aParams)
      [u][b] DATAFINAL = CDate(Mid(aParams,I+10,10))[/b][/u]
    End If

End Sub

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...