Advertisement

05.06.2008 at 08:44PM PDT, ID: 23381577
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Extracting a report from a Table in a flat database
Tags: Microsoft, Office, 2002
Hi all, I am stuck with a flat database Table that I need to extract a report from, The control is a Combo box which I think I need to control the Query with. The problem is that the Table contains all the records and the value I want to use as a control is one of the Column Values. Basically the structure is:
----------------------
Item Number,   Item Name,   truck1,  truck2,  truck3, etc, etc,
The Item number and Item Name are unique but the counts for the truck are not.
There is a Form which is used to enter and change data on the main Table. what I have been asked to do is produce a Report giving:
--------------
Item Number,   Item Name, and the totals for [Truck2]
AND alternatively to be able to select any truck..
I made a Query to look at the Table and just need some way to tell the Query that this time I want Truck2 totals or whatever.
Is it possible to grab  the Truck number from a Combo box on the Form? and pass it to the Query.
Or
Would it be easier to use a OnClick Function to make a Table matching the chosen Truck and run the Report against the new Table?
1:
2:
3:
4:
5:
6:
7:
8:
9:
heres what I made up [that doesn't work]
-------
SELECT Sheet1.[Item Number], Sheet1.[Item Name], [value] AS [Stock On]
FROM Sheet1
GROUP BY Sheet1.[Item Number], Sheet1.[Item Name]
HAVING ((("Value"=[Forms]![FrmSheet1]![Combo29])))
ORDER BY Sheet1.[Item Name];
---------------------
Yes! the Table is called Sheet1
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: Paulo357
Solution Provided By: harfang
Participating Experts: 2
Solution Grade: A
Views: 5
Translate:
Loading Advertisement...
05.06.2008 at 09:15PM PDT, ID: 21513137

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 01:01AM PDT, ID: 21514004

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 01:51PM PDT, ID: 21520259

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 01:53PM PDT, ID: 21520274

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 03:59PM PDT, ID: 21521087

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 04:22PM PDT, ID: 21521222

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 06:30PM PDT, ID: 21521707

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 06:53PM PDT, ID: 21521796

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 07:03PM PDT, ID: 21521825

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 07:07PM PDT, ID: 21521840

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 07:10PM PDT, ID: 21521848

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 07:12PM PDT, ID: 21521860

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 07:48PM PDT, ID: 21521970

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 04:54PM PDT, ID: 21529490

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 06:45PM PDT, ID: 21529905

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 06:57PM PDT, ID: 21529950

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 08:05PM PDT, ID: 21530188

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 08:46PM PDT, ID: 21530299

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.06.2008 at 09:15PM PDT, ID: 21513137

Rank: Guru

>HAVING ((("Value"=[Forms]![FrmSheet1]![Combo29])))
is Value a name of a field?
and what field/values are in Combo29?
 
05.07.2008 at 01:01AM PDT, ID: 21514004

Rank: Wizard

I'm afraid you will have to rewrite the query each time from code. Since your table isn't normalized, you cannot achieve that with SQL only.

    strSQL _
        = " SELECT [Item Number], [Item Name]" _
        & "  , Sum(" & Me.Combo29 & ") AS [Stock On]" _
        & " FROM Sheet1" _
        & " GROUP BY [Item Number], [Item Name]" _
        & " ORDER BY [Item Name]"

Then use the string as needed (source of a report, save as query, etc.). Note: I'm assuming some VB code run from the form FrmSheet1, hence the Me. keyword.

Good luck!
(°v°)
 
05.07.2008 at 01:51PM PDT, ID: 21520259
Frankytee
to reply to your entryfirst, do you agree with Harfabq comment? that as my table is not normalized we cannot reach a result via SQL. More info you asked for might help, I named a column in my query 'Value' without the brackets, and tried to populate it with the value in my text combo box off the form, this was my lame effort to control the query output to only bring out the records from the table relating to one particular vehicle.
 
05.07.2008 at 01:53PM PDT, ID: 21520274
harfanq,
I did consider making 12 individual qeries to draw off the table each vehicles figures, but poped this question here thinking it might be possible to still use the flat table to access one vehicle at a time, selecting via a combo control on a form. But apparently not possible?
 
05.07.2008 at 03:59PM PDT, ID: 21521087

Rank: Wizard

> But apparently not possible?

Well, technically, it is. Starting from normalized tables, it's very easy to reconstruct your present flat table. The opposite is not true: normalizing is never an efficient process, but it's possible in this case.

Consider the query below. It creates the normalized view, i.e. what your table should have been, or should become. You can then use this as source for any parametric query using the field TruckNb as filter. If your reconstruct what happens then, you will see that it forces Jet to run 12 queries, merge them, and then filter only 1 of them. This is very illogical and cannot be efficient.

Instead, rewriting the query through code {http:#a21514004} directly generates only one of the queries you see in the UNION query. This *is* efficient, if you need to work with a "flat" (or rather "horizontal") table.

Does that answer your question?
(°v°)
1:
2:
3:
4:
5:
6:
SELECT [Item Number], [Item Name], 1 AS TruckNb, Truck1 As Load FROM Sheet1 WHERE Truck1 Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 2, Truck2 FROM Sheet1 WHERE Truck2 Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 3, Truck3 FROM Sheet1 WHERE Truck3 Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 4, Truck4 FROM Sheet1 WHERE Truck4 Is Not Null
...
UNION ALL SELECT [Item Number], [Item Name], 12, Truck12 FROM Sheet1 WHERE Truck12 Is Not Null
Open in New Window
 
05.07.2008 at 04:22PM PDT, ID: 21521222
Great stuff H
But Iam afraid you are a couple of light years in front of me. I was just stitting here contemplating what Normalizing meant!
I read what your saying, that one can continue with this horizontal Table. but honestly I havent a clue on how to implement what your saying. I presume we are placing your code in a Module here? right.
Would it be easier for me to 'normalize' my Table... I take it that I would need to split it into three tables, one with the: Item number and Item Name in it. A second with The stock on tucks in it, and  athird with the Trucks in it. all linking via the row ID's right?
 
05.07.2008 at 06:30PM PDT, ID: 21521707
Harfanq
I have pasted your code smaple into the SQL section of my Query and the symbol has now changed to what I expect is a Union query two superimposed OO's [my first!]
BUT
when I run it I am prompted for Truck 1, then 2,3,4 etc through to 12 [as I added the missing ones]
Imputting anything into these popup's prompts only produces a Qery with whatever youve typed in it.
EG: Item number, Item Name, TruckNb, Load
Have I missed somthing?
Please continue

Cheers Paul
 
05.07.2008 at 06:53PM PDT, ID: 21521796
Experimenting... I have tried this one line to access Truck 12 data which is valid in the Table [Not Null]
The Column referring to Truck 12 is called 12 TK whith a space so I assume [again] I should bracket with " "
-----------
SELECT [Item Number], [Item Name],"12 TK" AS TruckNb, "12 TK" As Load FROM Sheet1 WHERE "12 TK" Is Not Null
-----------
This returns 12 TK is both columns TruckNb and Load
 
05.07.2008 at 07:03PM PDT, ID: 21521825

Rank: Wizard

Thanks!

> what Normalizing meant!

I won't offend you by pointing to Wikipedia pages or similar background readings of varying technical level. The point here is that you have columns that should be rows, and this is all I meant (at this point) by "normalizing".

> we are placing your code in a Module here?

In fact, it's just a query. If by any chance I haven't made any typos and if you are willing to fill in the blanks (at ...), this could be pasted into a new query in SQL view. There is no assistant to build UNION queries, so they need to be entered manually (although one can often copy-paste large portions from a previous query).

To get a feel for SQL, take the habit of reading the SQL view whenever you have built a new query. It quickly becomes quite readable.

> I would need to split it into three tables

Precisely, yes. The link between Items and Trucks is called a many-to-many relationship (same item type on several trucks and several items on each truck). The table with the "stock" is then called a link table, because it uses the keys from both tables, forming two one-to-many relationships.

Cheers!
(°v°)
 
05.07.2008 at 07:07PM PDT, ID: 21521840

Rank: Wizard

Sorry, missed your last posts (didn't refresh for a while).

> two superimposed OO's [my first!]

Congrats!

> I am prompted for Truck 1, then 2,3,4 etc

This means that the field names are not correct. Whenever you make a typo, the word becomes a "parameter" and you get prompted for it. In your question, you said the fields were truck1, truck2, etc. so this is what I used. If it's [Truck 1], [Truck 2], etc., you need to make the proper adjustments.

(°v°)
 
05.07.2008 at 07:10PM PDT, ID: 21521848

Rank: Wizard

Hint: try to make the first line work alone. The query assistant will be available to get the syntax right. Once the first line works, you should be able to adapt the others, or you can post back here so I have the correct names.

(°v°)
 
05.07.2008 at 07:12PM PDT, ID: 21521860
Thanks for the detail... great
Did you see my earlier post 1:30 & 1:53
I would like to run with what your providing... enjoying the learning

Paul
 
05.07.2008 at 07:48PM PDT, ID: 21521970

Rank: Guru

>to reply to your entryfirst, do you agree with Harfabq comment? that as my table is not normalized we cannot reach a result via SQL.

i've only skimmed the comments but generally yes, Harfang is right. with your data going across columns rather than rows you will cause yourself grief and making it harder than necessary.
The critical factor is that the underlying tables in a db should be normalized as H stated, and from then you can join to other tables, build your queries etc which can then form the basis of your reports.

so a report may not necessarily have to get its data directly from a normalised table (for eg its data source may be a "star" like schema) but by having normalised structure you can enforce data consistency and the ability to construct any query to drive your reports including the report output (the one with trucks as columns) that you used as the beginning in case you need to create that output for whatever reason.
 
05.08.2008 at 04:54PM PDT, ID: 21529490
This Union query stuff is perplexing...
This is what I have and poses a parameter query for trucks 9,10,11,12,14,15,16?
nothing for 12,1,2,3,4,5,6,7,8?
But returns the correct values, Should I just be happy it works or can anyone help as to why a cant get it working correctly, I would like the prompts to cease

Cheers Paul
 
05.08.2008 at 06:45PM PDT, ID: 21529905

Rank: Wizard

> This is what I have

You didn't include your query... We need one query that works (for example just selecting data for truck1 or for truck12), and the one that doesn't.

(°v°)
 
05.08.2008 at 06:57PM PDT, ID: 21529950
Sorry, mid blank:
-------------
SELECT [Item Number], [Item Name],12 AS TruckNb, [12TK]  As Stock FROM Sheet1 WHERE [12TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 2, [2TK] FROM Sheet1 WHERE [2TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 3, [3TK] FROM Sheet1 WHERE [3TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 4, [4TK] FROM Sheet1 WHERE [4TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 5, [5TK] FROM Sheet1 WHERE [5TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 6, [6TK] FROM Sheet1 WHERE [6TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 7, [7TK] FROM Sheet1 WHERE [7TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 8, [8TK] FROM Sheet1 WHERE [8TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 9, [9TK] FROM Sheet1 WHERE [9TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 10, [10TK] FROM Sheet1 WHERE [10TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 11, [11TK] FROM Sheet1 WHERE [11TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 13, [13TK] FROM Sheet1 WHERE [13TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 14, [14TK] FROM Sheet1 WHERE [14TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 15, [15TK] FROM Sheet1 WHERE [15TK] Is Not Null
UNION ALL SELECT [Item Number], [Item Name], 16, [16TK] FROM Sheet1 WHERE [16TK] Is Not Null;
-----------------
 
05.08.2008 at 08:05PM PDT, ID: 21530188

Rank: Wizard

I take it this works:

    SELECT [Item Number], [Item Name],12 AS TruckNb, [12TK]  As Stock
    FROM Sheet1 WHERE [12TK] Is Not Null

From what you are saying, we can also assume that this works, for example:

    SELECT [Item Number], [Item Name], 6, [6TK]
    FROM Sheet1 WHERE [6TK] Is Not Null

However this (or any other in 9,10,11,12,14,15,16) doesn't:

    SELECT [Item Number], [Item Name], 13, [13TK]
    FROM Sheet1 WHERE [13TK] Is Not Null

How come? Doesn't your table have a field called [13TK]? If you try this query alone, do you get prompted also? If you try to switch to design view, can you fix it? If yes, what is the correct SQL?

(°v°)
Accepted Solution
 
05.08.2008 at 08:46PM PDT, ID: 21530299

Rank: Wizard

Welcome, and success with your project (whether normalized or not)!

(°v°)
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628