Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I run a report or query on unlinked tables

Status
Not open for further replies.

JoeF

Technical User
Nov 30, 2000
54
0
0
US
I imported data into table in my database of planned products and thier projected sales. I didn't want to import the data into my current product table because a lot of info is missing on these new products and some of them may not end up being sold by my company. Is there any way for me to run a report that lists all the products (current and planned) without first combining these two tables with an append query?

The reason I don't want to run an append query is that I plan on updating this import table regularly and I would like to be able to run a report as above without making the combined table every time prior to running the report.
 
You can use a UNION query that would look something like this:

SELECT * FROM CurrentProducts
UNION SELECT * FROM PlannedProducts;

This is assuming both of your tables have similar fields.

Hope this helps,
Dusan
 
Yes, most of the fields are similar. I'll give this a shot. I have never worked with a union query and I have very little SQL experience, but the code seems simple enough. I think I'll create a query off the import table where I include the desired fields and make sure the fieldnames are exactly the same as the other table. Then I'll create a Union query to combine it with my product table. Fields that are missing from one of the two tables should just show up as blanks for records from those tables, right?

Thanks a lot!
 
Union query will fail if you try to combine two tables or queries that don't have the same number of fields. So, my suggestion is to make a query for each table pulling only the desired fields. If you want to pull a field from Products table that does not exist in your Import table, then you need to create a dummy field in your Import query that will "fill in the gap". You can do so by making this field a null expression:

FieldNameHere: ""

Take care that this dummy field is "aligned" with the field from the Products table. Also note that column names of the table/query that comes before the UNION statement drive the column names of the resulting query.

Dusan

 
Thanks for your help. This worked like a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top