Ola galera,
Tenho um problema grave no Access que é o seguinte: tenho várias colunas que são somadas em um loop no detalhe e o resultado é exibido no Rodapé do Relatório. Quando o relatório é exibido no monitor, maravilha, ele funciona perfeitamente, mas quando vou imprimir todos os totais saem dobrados
O que está havendo?
Valores Dobrados No Relatório Em Access!
Started By emogen, 13/06/2004, 08:05
1 reply to this topic
#2
Posted 14/06/2004, 08:51
Ai vai o código que fiz:
Código da Seção Detalhe
Private Sub Detalhe_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo trata
Dim SQL As String
Dim rs As New Recordset
Dim Horas, CustoFinal, total_horas_normais As Double
Dim I As Integer
For I = 1 To 3
Set rs = New ADODB.Recordset
If I = 1 Then
SQL = "select total_extra from t_horarios where datepart('w',data) in (2,3,4,5,6) and login='" & Me.ACESSOS.Text & "'"
ElseIf I = 2 Then
SQL = "select total_extra from t_horarios where datepart('w',data)=1 and login='" & Me.ACESSOS.Text & "'"
ElseIf I = 3 Then
SQL = "select total_extra from t_horarios where datepart('w',data)=7 and login='" & Me.ACESSOS.Text & "'"
End If
rs.Open SQL, _
CurrentProject.Connection, _
adOpenKeyset, _
adLockOptimistic
While Not rs.EOF
If Not IsNull(rs(0)) Then
Horas = Horas + CDbl(CDate(rs(0)))
End If
rs.MoveNext
Wend
If I = 1 Then
Me.txt_extra20.Value = Horas * 24
ElseIf I = 2 Then
Me.txt_extra50.Value = Horas * 24
ElseIf I = 3 Then
Me.txt_extra30.Value = Horas * 24
End If
Horas = 0
rs.Close
Set rs = Nothing
Next I
CustoFinal = CDbl(Me.cust_final.Text)
totalhorasnormais = totalhorasnormais + CDbl(Me.tot_horas_normais.Text)
totalhe = totalhe + CDbl(Me.tot_horas_adicionais.Text)
totcom = totcom + CDbl(Me.txt_comissao.Value)
totaj = totaj + CDbl(Me.tot_aj_custo.Value)
totcoop = totcoop + CDbl(Me.tot_cooperado.Value)
encprod = encprod + CDbl(Me.tot_encargos.Value)
encaj = encaj + CDbl(Me.encargos_ajcusto.Value)
vinss = vinss + CDbl(Me.tot_inss.Value)
Total_Parcial = Total_Parcial + CustoFinal
Exit Sub
trata:
Exit Sub
End Sub
Código que chama as variáveis da Seção Detalhe:
Private Sub RodapéDoRelatório_Print(Cancel As Integer, PrintCount As Integer)
Me.total_FINAL.Value = Total_Parcial
Me.txt_totg_hn.Value = totalhorasnormais
Me.txt_totg_he.Value = totalhe
Me.txt_tot_comissao.Value = totcom
Me.txt_totg_aj.Value = totaj
Me.txt_tog_coop.Value = totcoop
Me.txt_totg_encprod.Value = encprod
Me.txt_tog_encaj.Value = encaj
Me.txt_totg_inss.Value = vinss
End Sub
Código da Seção Detalhe
Private Sub Detalhe_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo trata
Dim SQL As String
Dim rs As New Recordset
Dim Horas, CustoFinal, total_horas_normais As Double
Dim I As Integer
For I = 1 To 3
Set rs = New ADODB.Recordset
If I = 1 Then
SQL = "select total_extra from t_horarios where datepart('w',data) in (2,3,4,5,6) and login='" & Me.ACESSOS.Text & "'"
ElseIf I = 2 Then
SQL = "select total_extra from t_horarios where datepart('w',data)=1 and login='" & Me.ACESSOS.Text & "'"
ElseIf I = 3 Then
SQL = "select total_extra from t_horarios where datepart('w',data)=7 and login='" & Me.ACESSOS.Text & "'"
End If
rs.Open SQL, _
CurrentProject.Connection, _
adOpenKeyset, _
adLockOptimistic
While Not rs.EOF
If Not IsNull(rs(0)) Then
Horas = Horas + CDbl(CDate(rs(0)))
End If
rs.MoveNext
Wend
If I = 1 Then
Me.txt_extra20.Value = Horas * 24
ElseIf I = 2 Then
Me.txt_extra50.Value = Horas * 24
ElseIf I = 3 Then
Me.txt_extra30.Value = Horas * 24
End If
Horas = 0
rs.Close
Set rs = Nothing
Next I
CustoFinal = CDbl(Me.cust_final.Text)
totalhorasnormais = totalhorasnormais + CDbl(Me.tot_horas_normais.Text)
totalhe = totalhe + CDbl(Me.tot_horas_adicionais.Text)
totcom = totcom + CDbl(Me.txt_comissao.Value)
totaj = totaj + CDbl(Me.tot_aj_custo.Value)
totcoop = totcoop + CDbl(Me.tot_cooperado.Value)
encprod = encprod + CDbl(Me.tot_encargos.Value)
encaj = encaj + CDbl(Me.encargos_ajcusto.Value)
vinss = vinss + CDbl(Me.tot_inss.Value)
Total_Parcial = Total_Parcial + CustoFinal
Exit Sub
trata:
Exit Sub
End Sub
Código que chama as variáveis da Seção Detalhe:
Private Sub RodapéDoRelatório_Print(Cancel As Integer, PrintCount As Integer)
Me.total_FINAL.Value = Total_Parcial
Me.txt_totg_hn.Value = totalhorasnormais
Me.txt_totg_he.Value = totalhe
Me.txt_tot_comissao.Value = totcom
Me.txt_totg_aj.Value = totaj
Me.txt_tog_coop.Value = totcoop
Me.txt_totg_encprod.Value = encprod
Me.txt_tog_encaj.Value = encaj
Me.txt_totg_inss.Value = vinss
End Sub
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)