Row 10 is net turnover for whom? A single entity (company or whatever)? A
group of businesses? Same question for Row 20. Let's back up a little.
What is the source of the Row 10 data? How is the number derived?
When you say PL consists of a certain number of rows, the question again is
about the source of the data in those rows. What do they have in common
with each other?
In Access, a table is where data are stored. A table row is a record, and a
table column is a field. A query can be thought of in the same way as a
table, in general, in terms of records and fields. There are some
differences, such as with crosstab queries, in terms of how they are
organized, but that can wait.
A table contains information about a single real-world entity such as
person, bank account information, etc. The information is broken into
distinct units (fields) that each contain a single piece of information. In
a People table, those fields would include FirstName, LastName, Phone, etc.
There needs to be a way to uniquely identify the person (a primary key).
One simple way of doing that is to add an autonumber field, which assigns a
unique number to each new record you create. The fields would not include
bank account information, because a bank account is not an attribute of a
person. Still using the example of the People table, a record is
information about one person.
If a person has a bank account, that information would be in a separate,
related table. A person could have one bank account or a dozen; they would
be separate records in that table. Each record includes a field (the
foreign key) that corresponds to the primary key field in the People table.
Taking it a step further, each bank account contains a number of separate
transactions. There is another table, related to the Account table, for
these Account Details.
It is a fairly simple matter in Access to sum something like the DebitAmount
field from the AccountDetails table, either for a single Account or for a
group of Accounts. An important distinction from Excel is that you can
select any group of cells, and enter a calculation for those fields in
another cell. You can do that in Access, too, but the mechanism is very
different.
Take a look at Allen Browne's Tips for Casual Users:
http://allenbrowne.com/tips.html. Such information is included in a number
of other sites, too. Allen is one among many who have made their expertise
available to the general public. Another site is
http://www.mvps.org/access/. Both sites contain links to many other
resources.
Aivars said:
Hello, BruceM,
Thanks for your advice
Yes, I am coming from Excel world into Access and as I said i am very new
to Access. In Excel it is very easy to sum two rows above but Access is
different.
The reason I want to group and sum rows 10 and 20 is simple - this is/will
be a company financial profit and loss account
And row 10 is Net turnover. Row 20 is Cost of Sales. Net turnover is with
negative (-) sign, cost of sales positive (+) number. So summing these two
together I get Gross Profit (Net turnover - Cost of Sales = Gross Profit)
Probably i should rethink the way as how do I calculate the profit and
loss account (PL) in Access. Generaly speaking PL account consists of a
certain amount of rows (15) which are returned by query and then these
rows shud be grouped together on a report in specific way enabling to see
the Gross Profit, Profit before taxes, and Period Profit.
Will try now your suggestion with running sums
Aivars
BruceM said:
There was really nothing in your original post (at least not that I could
see) to explain why you would sum RowNo 10 and 20 to produce the result
in RowNo 30. Similarly, there is no way to know why you would sum 40,
60, and 70 to create a new line 70. Your question suggests that you are
thinking of the query as a spreadsheet. Without knowing anything about
the real-world situation you are trying to address, there is no way to
suggest a solution.
Having said that, if there is a reason 10 and 20 are grouped together you
can group the report by the appropriate field, then bind a text box on
the report to that field. Set the Running Sum property for that text box
(I iwll call it txtRunSum) to Over Group. This will show the cumulative
result in each record, so if you want to see just the final total, set
the Visible property of txtRunSum to No, and place a text box into the
group footer with its Control Source set to =[txtRunSum].