473,602 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ 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 1586
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.Nam e
FROM MSysObjects
WHERE (((MSysObjects. Name) Not Like "msys*" And (MSysObjects.Na me) Not
Like "all*") AND ((MSysObjects.T ype)=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,ke ep 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,ke ep 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

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

Similar topics

9
3120
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 SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
7
5957
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 details invovling that computer, for the user to then view. Any ideas on some code? Many thanks for any help.
4
2062
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 premiums are dependant on the country in which the client is in. Therefore, we have a Country table, with its list of rates, a client table and then the property table. Getting this is great, works fine, easy! Problem is, now I need to work out a...
4
2854
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 query. I'm having trouble doing it. Help! Here is my code so far: Sub OldRegionQuery()
36
3014
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 have set up a Query to show only records that meet a certain criteria...therefore excluding all of the records that do not meet this criteria (just for the record the criteria is any record within my database that falls within two months of its "Due...
5
7357
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 same command inside of mysql_real_query and I keep on getting this error back. "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
10
6218
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 cross-tab query I am using a simple query with no grouping where I am filtering some data out in the criteria line. I have been out of access for a couple years but I remember in the past I had a solution for this but I can't remember. Any help...
11
16299
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. We have been using oracle client 10.1.0.2 with it's odbc for a while without problem. The problem arose when we decided to reconnect all the tables and save password. Some query became suddenly very slow. Then I've discovered that the tables...
4
2037
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 with MS Access and VBA. I desperately need help with 2 queries that I am trying to put together. I want to thank anyone that can help me out with this situation. I want to put a select query(Query1) that uses one table and the criteria would...
6
4392
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 field between them. The join field in both tables are indexed and I'm selecting 1 field from each table to lookup. The Access query is taking more than 60 second to retrieve 1 record and if I execute the same query within the Query Analyzer, it...
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2418
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 we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.