Tables, queries

  • Thread starter Thread starter Pam
  • Start date Start date
P

Pam

I have a table. The information I want to populate the
fields is the sum of information from other tables. How do
I do this?
 
Hi,

A table name cannot be a parameter, so you have few choices short of:

SELECT SUM(f1) FROM table1
UNION ALL
SELECT SUM(g1) FROM table2
UNION ALL
...

That would return N records with one field, the "summation" for each
table.


If you just need THE total:


SELECT
SUM(f1) + ( SELECT SUM(g1) FROM Table2) + (SELECT SUM(h1) from Table3)
+ ...
FROM Table1



Hoping it may help,
Vanderghast, Access MVP
 
Hello Pam:

I believe that you are asking if you can have calculated
values from other tables populate your table. What you can
do is (1)create a make table query that calculates that
values you are looking for from the source tables. From
there (2)create a table that will hold the necessary data.
The make table query will ask you for a table name. Make
sure that you name your new table the same as the table
that will be created by the make table query. (3) Create a
macro named AUTOEXEC that will run this query whenever the
database is opened. Naming a macro AUTOEXEC is an Access
95 trick that causes the macro to run whenever the
database is opened. This will assure that the values are
refreshed whenever you open the database.
 
Back
Top