473,480 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

query help...

145 New Member
Here is the db with sample data.

http://download.yousendit.com/AAA18BC7520F196E

I want to use qryCrosstab and table "ALL" to achieve the result that would look like this query "qryFinalResult".

Table [ALL] has a field called filename and it stores the table names that qryFinalResult is using.

Is it Possible ????

Can someone please please help ? stuck with this for last 48 hours.
Feb 22 '07 #1
11 1572
dorandoran
145 New Member
Can someone pleas help ?

1. I use a vba to import bunch of excel files into individual tables.
Tables are named after the excel file. A field is created in these new
tables called "FileName" and it's populated with the filename.

2. I am doing this so I know what file the data came from

3. table "ALL" gets populated with all of these excel data and the
name of the file.

The crosstab is taking [ALL] table and aggegating hours, comp and
other data elements.

FinalResult is takign the crosstab and i m doing right join to pull
data from crosstab and all the data from each tables.

Is there a way I can only use table [ALL] and qrycrosstab to make my
look like qrufinalresult ?

Is there a vba that will do right join automatically between crosstab
and all the table in import (except table ALL)?

Here is the query that gives me all the table name.

SELECT DISTINCT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "msys*" And (MSysObjects.Name) Not
Like "all*") AND ((MSysObjects.Type)=1));
Feb 22 '07 #2
dorandoran
145 New Member
Forum Owners: DELETE THIS POST IF NO ONE GOING TO ANSWER IT. I AM REALLY FRUSTRATED AND BEGGING FOR SOME HELP OR DIRECTIONS.
Feb 22 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Forum Owners: DELETE THIS POST IF NO ONE GOING TO ANSWER IT. I AM REALLY FRUSTRATED AND BEGGING FOR SOME HELP OR DIRECTIONS.
Every effort is made to answer questions promptly but you have to be patient. All experts volunteer their time and your question will be attended to.

However, I will point out a couple of things. Most experts won't want to download your database onto their systems so you will help yourself by providing more information.

Post the metadata of all the tables invovled.
Posting Table/Dataset MetaData
Expand|Select|Wrap|Line Numbers
  1. Table Name=tblStudent
  2. StudentID; Autonumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. MaxMark; Numeric
  7. MinMark; Numeric
Post the SQL code of the crosstab query as well as any other queries involved.

Mary
Feb 23 '07 #4
dorandoran
145 New Member
I am thinking of two different approach

Approach # 1 : Since all the data in tabl [ALL] , I would just like just this table with crosstab query made from this to make a query that will give same result that qryFinalResult does.

Approach # 2:
a. Create a query that will list all the tables except table [ALL]
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT DISTINCT MSysObjects.Name
  3.        FROM MSysObjects
  4.        WHERE (((MSysObjects.Name) Not Like "msys*" And & _    
  5.        (MSysObjects.Name) Not Like "all*") AND ((MSysObjects.Type)=1));
b. Then use VBA to create right join from table [ALL] to these table
using ssn number.

Please let me know.

qryCrosstab
Expand|Select|Wrap|Line Numbers
  1.  
  2. TRANSFORM Sum([All].FileName) AS SumOfFileName
  3. SELECT [All].SocSecNum, Min([All].[Birth Date]) AS [MinOfBirth Date], Min([All].[Hire Date]) AS [MinOfHire Date], Max([All].Termination) AS MaxOfTermination, Max([All].[Rehire Date]) AS [MaxOfRehire Date], Sum([All].Compensation) AS SumOfCompensation, Sum([All].[Excluded Comp]) AS [SumOfExcluded Comp], Sum([All].Hours) AS SumOfHours, Sum([All].[Aniv Hours]) AS [SumOfAniv Hours], Sum([All].[History Comp]) AS [SumOfHistory Comp], Sum([All].[History Ex Comp]) AS [SumOfHistory Ex Comp]
  4. FROM [All]
  5. GROUP BY [All].SocSecNum
  6. PIVOT [All].FileName;

qryFinalResult
Expand|Select|Wrap|Line Numbers
  1. SELECT qryCrosstab.SocSecNum, qryCrosstab.[MinOfBirth Date], qryCrosstab.[MinOfHire Date], qryCrosstab.MaxOfTermination, qryCrosstab.[MaxOfRehire Date], qryCrosstab.SumOfCompensation1 AS Expr1, qryCrosstab.[SumOfExcluded Comp], qryCrosstab.SumOfHours, qryCrosstab.[SumOfAniv Hours], qryCrosstab.[SumOfHistory Comp], qryCrosstab.[SumOfHistory Ex Comp], qryCrosstab.[1110], qryCrosstab.[1317], qryCrosstab.[328], qryCrosstab.[429], qryCrosstab.[465], [328].Compensation, [328].[Excluded Comp], [328].Hours, [328].[Aniv Hours], [328].[Birth Date], [328].[Hire Date], [328].Termination, [328].[Rehire Date], [328].[History Comp] AS Expr1, [328].[History Ex Comp] AS Expr2, [429].Compensation, [429].[Excluded Comp], [429].Hours, [429].[Aniv Hours], [429].[Birth Date], [429].[Hire Date], [429].Termination, [429].[Rehire Date], [429].[History Comp] AS Expr3, [429].[History Ex Comp] AS Expr4, [465].Compensation, [465].[Excluded Comp], [465].Hours, [465].[Aniv Hours], [465].[Birth Date], [465].[Hire Date], [465].Termination, [465].[Rehire Date], [465].[History Comp] AS Expr5, [465].[History Ex Comp] AS Expr6, [1110].Compensation, [1110].[Excluded Comp], [1110].Hours, [1110].[Aniv Hours], [1110].[Birth Date], [1110].[Hire Date], [1110].Termination, [1110].[Rehire Date], [1110].[History Comp] AS Expr7, [1110].[History Ex Comp] AS Expr8, [1317].Compensation, [1317].[Excluded Comp], [1317].Hours, [1317].[Aniv Hours], [1317].[Birth Date], [1317].[Hire Date], [1317].Termination, [1317].[Rehire Date], [1317].[History Comp] AS Expr9, [1317].[History Ex Comp] AS Expr10
  2. FROM 1317 RIGHT JOIN 
  3. (1110 RIGHT JOIN 
  4. (((qryCrosstab LEFT JOIN 328 
  5. ON qryCrosstab.SocSecNum = [328].SocSecNum)
  6. LEFT JOIN 429 
  7. ON qryCrosstab.SocSecNum = [429].SocSecNum)
  8. LEFT JOIN 465 
  9. ON qryCrosstab.SocSecNum = [465].SocSecNum)
  10. ON [1110].SocSecNum = qryCrosstab.SocSecNum) 
  11. ON [1317].SocSecNum = qryCrosstab.SocSecNum;
Feb 23 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
I'm afraid I'm still a little confused about what you are trying to do.

Are you just trying to count the number of records in each table using a cross tab query and displaying the fields as laid out in the other query.

Mary
Feb 23 '07 #6
dorandoran
145 New Member
Yes,

I am trying to display all the fields from qryCrosstab and also display fields from each table across.
Feb 23 '07 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
Looking at the information involved I would have to take a guess and say it can't be done. Adding all the extra fields will not allow you to group the crosstab query to give you a record count.

Mary
Feb 23 '07 #8
dorandoran
145 New Member
Hi Mary,

Here is how it's working. We receive census data from large clients like american express who has multiple sub companies. Employees moves from sub-company to sub-company. At the end of the year we receive census files from each sub-company.

We take the census data from each sub-copany and aggregate their hours, compensation,keep oldest hire date, keep recent term date and other data elements. This is what qyrCrosstab is doing.

Now in the final result we want to be able to display employees aggregate data and the original data across.

for example, if an employess listed in table 222 and 432 and 1452 then the result should look like below

ssn dob doh dot dor agg_comp agg_hrs 222.dob 222.doh 222.dot 222.dor

and so forth.

I am sorry if my issue is not clear. I understand it can be little confusing. I hope it's lil bit clear now.

Thanks everyone looking into this. I really appreciate it.
Feb 23 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Mary,

Here is how it's working. We receive census data from large clients like american express who has multiple sub companies. Employees moves from sub-company to sub-company. At the end of the year we receive census files from each sub-company.

We take the census data from each sub-copany and aggregate their hours, compensation,keep oldest hire date, keep recent term date and other data elements. This is what qyrCrosstab is doing.

Now in the final result we want to be able to display employees aggregate data and the original data across.

for example, if an employess listed in table 222 and 432 and 1452 then the result should look like below

ssn dob doh dot dor agg_comp agg_hrs 222.dob 222.doh 222.dot 222.dor

and so forth.

I am sorry if my issue is not clear. I understand it can be little confusing. I hope it's lil bit clear now.

Thanks everyone looking into this. I really appreciate it.
You can display in down but displaying it accross just using queries is very difficult.

The solution would be better proposed using recordsets. But this would require a table be created to store the data and how would you decide the number of tables involved. What is the largest number of possible tables.

I understand now what you are trying to do but don't think it's possible to represent the data accross because of the number of tables involved.

The solution I would look at is to create a master list of employees with date of birth and first table they are on. Then relate their entry in that table with a foreign key in all the other tables they appear in.

For example if they first appear in 222 and then in 432 then have a field in 432 table where for this record 222 is entered this can also be entered in table 222. Then everytime you reference employee x from the master list
you look up all tables where 222 is entered and return the data.

Sorry I can't think of another better solution to your problem.

Mary
Feb 23 '07 #10
MMcCarthy
14,534 Recognized Expert Moderator MVP
Also have a look at this question to see if there is anything here that can help.

Combining Rows-Opposite of Union


Mary
Feb 23 '07 #11
Rux
3 New Member
I'm Trying to get into the problem but I'm still confused.
Please try to explain some more the process
Feb 23 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3103
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
5942
by: Simon Bailey | last post by:
How do you created a query in VB? I have a button on a form that signifies a certain computer in a computer suite. On clicking on this button i would like to create a query searching for all...
4
2048
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
4
2846
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
36
2978
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
5
7340
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the...
10
6192
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
11
16277
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
4
2026
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
6
4365
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
0
6905
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6908
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5331
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4478
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.