Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Display detailed data, subtotals and totals in an Access2007 table.
Display detailed data, subtotals and totals in an Access2007 table.
Problem description: How to display details, subtotals and totals in an access2007 table at the same time?

Id card full name salary

2a 500.00 yuan

4a 600.00 yuan

5a 700.00 yuan

600 yuan Renminbi

7b 55.00 Yuan

In Access2007, tables with the above format should be subtotaled according to the full name, and then all these tables should be summed up in the following format. How to finish them?

Full name salary

700 yuan Renminbi

600 yuan

500 yuan Renminbi

A Subtotal ¥ 1, 800.00

55 dollars

800 yuan Renminbi

B Subtotal 855.00 yuan

Total ¥ 2,655.00

Answer: First of all, we should understand that tables are used to store data, not to display statistical results and show them to end users. Similar work should be done in an Access2007 report, which can be grouped and displayed with subtotals. For details, please refer to the help or the report in the north wind. MDB sample database.

Secondly, there is a special part in ADO called data shaping, which is used to complete the above work, but it needs to be displayed with VB DATAGRID and other controls. Some VB controls can also be used in forms in Access2007.

Finally, if you really want to use the form of Access2007, you can do it by organizing JET SQL to generate queries.

Select full name to pay from payment.

Used to find out the details

Choose to pay. full name

"Subtotal" is the expression 1, and Sum(pay.pay) is payAll.

From the salary

GROUP BY pay.fullname

"Subtotal"

Subtotal for classified summary. Pay attention to the above skills. Adding "Subtotal" next to the FULLANME field is not just for good looks. It is entirely up to FULLNAME to put the subtotal line under the detail. You can arrange the display order of this line by adjusting it.

Select "Total" to select the total (payment) from the payment.

Used to display the total count. Please note that the ANSI encoding of the word "total" must be greater than any character in the FULLNAME field, otherwise the total count cannot be placed in the bottom row of the table according to the FULLNAME sorting. Tip: When "total" cannot be used, other characters or even symbols can be used, as long as its machine code is large enough.

Organizing the above statements with UNION ALL can achieve the expected effect.

Select full name to pay from payment.

Joint ownership

Choose to pay. full name

"Subtotal" is the expression 1, and Sum(pay.pay) is payAll.

From the salary

GROUP BY pay.fullname

"Subtotal"

Joint ownership

Select Total to select the sum (payment) from the payment.

Sort by full name