Existe 1 campo na tabela pra lancamento em dinheiro e outro para credito
seria este codigo acima ?
Grato
seria este codigo acima ?
Grato
Me.SuaCaixaTexto = Nz(DSum("[PagoDinheiro]", "TblVenda", "[Ano])= [AnoRef] and [Empresa] = 'EmpresaA'"), 0)
Private Sub AnoRef_AfterUpdate()
Me!LstEmpresaA.RowSource = ""
Me!LstEmpresaA.AddItem "Ano;Mês;Empresa;TotalVendas;TotalCompras"
Me!V1 = 0: Me!V2 = 0
Me!B1 = 0: Me!B2 = 0
Me!LstEmpresaB.RowSource = ""
Me!LstEmpresaB.AddItem "Ano;Mês;Empresa;TotalVendas;TotalCompras"
Me!V3 = 0: Me!V4 = 0
Me!B3 = 0: Me!B4 = 0
If Nz(Me!AnoRef) = "" Then Exit Sub
Call fncFazLista1
Call fncFazLista2
End Sub
Private Sub fncFazLista1()
Dim i As Byte
Dim rs As DAO.Recordset
Dim arrValor(1 To 12, 1 To 2) As Currency
Dim arrValor2(1 To 12, 1 To 2) As Currency
Dim arrValor3(1 To 12, 1 To 2) As Currency
Dim strEmpresa, strFantasia As String
strEmpresa = "EmpresaA"
strFantasia = "EmpresaB"
Set rs = CurrentDb.OpenRecordset("SELECT * " & _
"FROM QryVendas " & _
"WHERE Ano = " & Me!AnoRef & " And Empresa = '" & strEmpresa & "' " & _
"ORDER BY Mês;", 8)
While Not rs.EOF
arrValor(rs.Fields(1), 1) = rs.Fields(3)
arrValor2(rs.Fields(1), 1) = rs.Fields(4)
arrValor3(rs.Fields(1), 1) = rs.Fields(5)
rs.MoveNext
Wend
rs.Close: Set rs = Nothing
Set rs = CurrentDb.OpenRecordset("SELECT * " & _
"FROM QryCompras " & _
"WHERE Ano = " & Me!AnoRef & " And Empresa = '" & strFantasia & "' " & _
"ORDER BY Mês;", 8)
While Not rs.EOF
arrValor(rs.Fields(1), 2) = rs.Fields(3)
rs.MoveNext
Wend
rs.Close: Set rs = Nothing
For i = 1 To 12
Me!LstEmpresaA.AddItem Me!AnoRef & ";" & StrConv(MonthName(i), vbProperCase) & ";" & strEmpresa & ";R$ " & Format(arrValor(i, 1), "Standard") & ";R$ " & Format(arrValor(i, 2), "Standard")
Me!V1 = Me!V1 + arrValor(i, 1): Me!V2 = Me!V2 + arrValor(i, 2)
Me!B1 = Me!B1 + arrValor2(i, 1): Me!B2 = Me!B2 + arrValor3(i, 1)
Next i
End Sub
Private Sub fncFazLista2()
Dim i As Byte
Dim rs As DAO.Recordset
Dim arrValor(1 To 12, 1 To 2) As Currency
Dim arrValor2(1 To 12, 1 To 2) As Currency
Dim arrValor3(1 To 12, 1 To 2) As Currency
Dim strEmpresa As String
strEmpresa = "EmpresaB"
strFantasia = "EmpresaA"
Set rs = CurrentDb.OpenRecordset("SELECT * " & _
"FROM QryVendas " & _
"WHERE Ano = " & Me!AnoRef & " And Empresa = '" & strEmpresa & "' " & _
"ORDER BY Mês;", 8)
While Not rs.EOF
arrValor(rs.Fields(1), 1) = rs.Fields(3)
arrValor2(rs.Fields(1), 1) = rs.Fields(4)
arrValor3(rs.Fields(1), 1) = rs.Fields(5)
rs.MoveNext
Wend
rs.Close: Set rs = Nothing
Set rs = CurrentDb.OpenRecordset("SELECT * " & _
"FROM QryCompras " & _
"WHERE Ano = " & Me!AnoRef & " And Empresa = '" & strFantasia & "' " & _
"ORDER BY Mês;", 8)
While Not rs.EOF
arrValor(rs.Fields(1), 2) = rs.Fields(3)
rs.MoveNext
Wend
rs.Close: Set rs = Nothing
For i = 1 To 12
Me!LstEmpresaB.AddItem Me!AnoRef & ";" & StrConv(MonthName(i), vbProperCase) & ";" & strEmpresa & ";R$ " & Format(arrValor(i, 1), "Standard") & ";R$ " & Format(arrValor(i, 2), "Standard")
Me!V3 = Me!V3 + arrValor(i, 1): Me!V4 = Me!V4 + arrValor(i, 2)
Me!B3 = Me!B3 + arrValor2(i, 1): Me!B4 = Me!B4 + arrValor3(i, 1)
Next i
End Sub