I have a temp table (TEMP) that is what the data is uploaded into.
(Field1 -
Text, Field 2 - Number, Field 3 - Currency, Field 4 - Number, Field 5 -
Currency ...Field 16 - Number, Field 17 - Currency)
I have a another temp table (Resource TEMP) that renames the fields of
the
temp table. (Customer - Text, Count01 - Number, Cost01 - Currency,
Count02 -
Number, Cost02 - Currency ...Count08 - Number, Cost08- Currency)
I have a resource table (Resources) that assigns a resource number to
items
that I'm charging for. (Ie: Blackberry...etc.) (Resource - Text,
Description
- Text, Active - yes/no)
I have a SortOrder table (SortOrder) that sorts the customers so that
they're in the correct order in the end. (SortOrder - Number,
Customer -
text)
And I have a Master table (Master Table) that lists each record
(Month -
date, SortOrder - number, Customer - text, Resource - text, Count -
Number,
Cost - Currency)
For costs:
TRANSFORM Sum([Query 2].Cost) AS SumOfCost
SELECT [Query 2].SortOrder, [Query 2].Customer, [Query 2].Resource,
[Query
2].Description
FROM [Query 2]
GROUP BY [Query 2].SortOrder, [Query 2].Customer, [Query 2].Resource,
[Query
2].Description
PIVOT [Query 2].Month;
For counts:
TRANSFORM Sum([Query 2].Count) AS SumOfCount
SELECT [Query 2].SortOrder, [Query 2].Customer, [Query 2].Resource,
[Query
2].Description
FROM [Query 2]
GROUP BY [Query 2].SortOrder, [Query 2].Customer, [Query 2].Resource,
[Query
2].Description
PIVOT [Query 2].Month;
The goal of this project is to have one table (that looks exactly like
the
table that I imported from excel) that is a sum of all the inputted
months
for each customer and item.
This is the SQL view of the resulting query that I currently have.
SELECT [Query 5_Count].Customer, [Query 5_Count].[01 Blackberry],
[Query
5_Cost].[01 Blackberry], [Query 5_Count].[02 Sametime], [Query
5_Cost].[02
Sametime], [Query 5_Count].[03 Docushare], [Query 5_Cost].[03
Docushare],
[Query 5_Count].[04 eRoom], [Query 5_Cost].[04 eRoom], [Query
5_Count].[05
Secure ID], [Query 5_Cost].[05 Secure ID], [Query 5_Count].[06 Verisign
ICEA
Certs], [Query 5_Cost].[06 Verisign ICEA Certs], [Query 5_Count].[07
SSL
Entrust Certs], [Query 5_Cost].[07 SSL Entrust Certs], [Query
5_Count].[08
Wildcard Certs], [Query 5_Cost].[08 Wildcard Certs]
FROM [Query 5_Cost] INNER JOIN [Query 5_Count] ON [Query
5_Cost].Customer=[Query 5_Count].Customer;
Thanks for all your help so far,
Jennifer
:
Hi Jennifer
I do have master tables and queries that list out each record...if
that
helps.
That is GREAT news! it means we don't have to go back and redesign
your
tables
Can you please post a description of the relevant tables with field
names
and data types?
Also, can you please post the SQL from the query that produces the
month
columns (open the query, then click View>SQL view and copy and paste
from
the window).
I'm thinking you can probably generate a query on the fly to get what
you
want, so please tell me as accurately as possible what you want to
display
in your form/report.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Okay let me start by saying I am pretty new to Access. And yes the
months
are the columns. I didn't know how else to get a sum.
I do have master tables and queries that list out each record...if
that
helps.
:
Hi Jennifer
Do you need the exact sendkeys?
No - that would be far too scary!
Actually, what is most scary here is that it looks like you have a
separate
column (field) in your table for each month. Is that the case? Or
is
this a
crosstab query?
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
My query looks like this:
Sort Customer Description 01/2008 02/2008
03/2008
SUM: [01/2008] +[02/2008]+[03/2008]
When I send keys I basically use arrows to get to the SUM column,
insert a
column, use arrows to get to the most recent month, enter, save.
Then
I
tab
over to get back to SUM, build, add +, add most recent month,
enter,
save,
close.
I have to do this for 2 queries and its the exact same process.
(one
for
cost and the other for count)
Do you need the exact sendkeys?
:
Hi Jennifer
There is almost always an alternative to SendKeys.
Tell us more about what you are trying to do and how you are
currently
achieving it (or not!) with SendKeys.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
I import a file monthly into Access and through a series of
queries I
output
one table that lists customers and the counts of items and how
much
it
costs
summed up to the current date.
IE:
Upload:
May 2008
Customer Item 1 Cost 1 Item 2 Cost 2
C1 25 $25 4
$100
C2 10 $10 0
$0
Output:
Customer Item 1 Cost 1 Item 2 Cost 2
C1 254 $254 64
$256
C2 213 $213 0
$0
The Output represents the sum of all of the current months.
In order to get the sum, I run a macro that sends a lot of
keys
in
order
to
add the new month to the query and then to add it to the sum.
Is there a way to use VBA code to do this? I'm having trouble
with
the
sending keys, sometimes it works and most of the time it
breaks.