Return the total value of items calculated in a list

Asked

Viewed 694 times

8

I have a table with Quant and Preço.
On the form, beyond these fields, I have the field Total = [Quant]*[Preço]

Also, in the main form I have the field SomaTotal = Soma([Total])

That is, the classic sum of prices that everyone knows how to make.

Question:

How do I put that total on a Sales list?

That is, I have this total for each sale, but I needed a list that would return me all sales, and the total of each of them.

I’d have to make a nested consultation?

Captura de Tela

The image is illustrative. I need this list on MS Access.

  • 1

    Are you doing this via SQL or otherwise? (sorry ignorance, I don’t know anything about MS Access) If it is via SQL, look for GROUP BY. Otherwise, it has an article which explains step-by-step how to do this using the "Report Wizard" (Report Wizard). P.S. I would post this as an answer, but as I said, total ignorance in Access, would end up just talking nonsense...

  • 1

    #mgibsonbr the word GROUP BY helped me. I made a query SQL: SELECT detVendas.id, Sum([Quant]*[Preco]) AS Total FROM detVendas GROUP BY detVendas.id; Thanks

  • @Regisdasilva if you want, you can add your comment as the answer to the question, and accept as the correct answer. Facilitates for those who want to search in the future on the site...

2 answers

3

In Msaccess you can create fields and put their value equal to another form field / report.

In your case, if I understand correctly, you will make a form that calculates the total of 3 sales, and then you want in another part of the same form appear only the total of each sale (as if it were a summary), and maybe the overall total (adding up the 3 sales), this ?

Enter a method in the Afterupdate property of your total of each sale (which is 4044 and 2280 in your example) and have it update the other field.

Example:

Private Sub TotalVenda1_AfterUpdate()

    Me.[TotalGeral1] = Me.[TotalVenda1]

End Sub

1


I made an SQL query:

SELECT detVendas.id, Sum([Quant]*[Preco]) AS Total FROM detVendas GROUP BY detVendas.id;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.