Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 5th, 2003, 04:56 PM
CrimsonGryphon CrimsonGryphon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 9 CrimsonGryphon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Creating a Report from 3 Tables

I have 3 inventory tables: Computer, Server and Printer. each tables primary key is a autonumber

I have 3 data reports that list the inventory in each that use a SQL query to do it. such as

Select ProductType, ProductName, UnitsInStock FROM ComputerInventory ORDER BY ProductType

Is there a way to create a report that can combine all those and list the inventory in all 3 tables, in essence a total inventory report? i'm not too keen on the data environment and reports but i'm just wondering if its possible. i'm not sure if i really need it but if its doable it might be nice to have

Thanks

Reply With Quote
  #2  
Old December 5th, 2003, 05:10 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,982 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 42 m 27 sec
Reputation Power: 814
Look at the sql UNION statement.

Reply With Quote
  #3  
Old December 5th, 2003, 10:44 PM
D·Hack D·Hack is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 D·Hack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yeah, check out the UNION, the JOIN and something else that I forgot the name of...

If you still need more help, hit me back. I headed a small team that wrote a VB/database application which managed an entire database including reports. I'll try to dig up the code for that, but I might have lost it in my last hard drive failure.

Reply With Quote
  #4  
Old December 5th, 2003, 10:57 PM
CrimsonGryphon CrimsonGryphon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 9 CrimsonGryphon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i tried the UNION thing, heres what i did in the sql builder for the reports

SELECT ComputerPartName, ComputerPartDesc, UnitsInStock
FROM ComputerInventory
ORDER BY ComputerPartName
UNION
SELECT ServerPartName, ServerPartDesc, UnitsInStock
FROM ServerInventory
ORDER BY ServerPartName
UNION
SELECT PrinterPartName, PrinterPartDesc, UnitsInStock
FROM PrinterInventory
ORDER BY PrinterPartName

gave me a error saying UNION wasn't allowed

I also tried this when i changed the autonumbered primary key of the 3 tables to the same field name of just PartNumber

SELECT ComputerPartName.ComputerInventory, ComputerPartDesc.ComputerInventory, UnitsInStock.ComputerInventory, ServerPartName.ServerInventory, ServerPartDesc.ServerInventory, UnitsInStock.ServerInventory, PrinterPartName.PrinterInventory, PrinterPartDesc.PrinterInventory, UnitsInStock.PrinterInventory
FROM ComputerInventory, ServerInventory, PrinterInventory
WHERE (PartNumber.ComputerInventory = PartNumber.ServerInventory)
AND (PartNumber.ServerInventory = PartNumber.PrinterInventory)
AND (PartNumber.ComputerInventory = PartNumber.PrinterInventory)


and i the above with just the computer and server tables and it didn't work either. I have a book called a guide to SQL and what i did looks just like whats in the book but its not coming out the same way.

Any suggestions?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Creating a Report from 3 Tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT