Union Query

N

nybaseball22

Hello. I am trying to create a UNION query out of my current query.
The query is used as a filter for a form after it opens and pulls
input for 2 fields from a form I have open. The SQL for the Query is
below. I want to add an ALL choice to 2 list boxes I have. The list
boxes have my Cars and Actions.

Thank you.

SQL

SELECT [Automobiles - Main Table].Car, [Automobiles - Main
Table].Action, [Automobiles - Main Table].Mileage, [Automobiles - Main
Table].AutoDate, [Automobiles - Main Table].Location, [Automobiles -
Main Table].Cost, [Automobiles - Main Table].Notes, [Automobiles -
Main Table].Problems, [Automobiles - Main Table].Comments
FROM [Automobiles - Main Table]
WHERE ((([Automobiles - Main Table].Car)=[Forms]![AutomobileSearch]!
[CarList]) AND (([Automobiles - Main Table].Action)=[Forms]!
[AutomobileSearch]![EventList]))
ORDER BY [Automobiles - Main Table].Car, [Automobiles - Main
Table].Mileage DESC;
 
N

nybaseball22

If you can't help with my question, please don't respond. Maybe
others can help. This did nothing for me.
 
J

Jeanette Cunningham

I had another look at that site and I can see that it doesn't explain
everything you might need to know. It could explain the topic better, I
won't refer people to it again.
The second query to add to make the union query will look something like
this:

SELECT "<ALL cars>", Null as Action, Null as Mileage, Null as AutoDate etc
FROM [Main Table]

Note: the query above must have the same number of fields as the query that
you are going to union it with. To complete the Select statement above you
need to add Null as [name of field], until you have covered all the fields
in the query below - I counted 9 fields.
The second query stays the same as it is except for the ORDER BY clause.
Change it to ORDER BY Car, Mileage Desc

You will need to do a similar thing to create the query for the second
listbox for all actions.

SELECT [Automobiles - Main Table].Car, [Automobiles - Main
Table].Action, [Automobiles - Main Table].Mileage, [Automobiles - Main
Table].AutoDate, [Automobiles - Main Table].Location, [Automobiles -
Main Table].Cost, [Automobiles - Main Table].Notes, [Automobiles -
Main Table].Problems, [Automobiles - Main Table].Comments
FROM [Automobiles - Main Table]
WHERE ((([Automobiles - Main Table].Car)=[Forms]![AutomobileSearch]!
[CarList]) AND (([Automobiles - Main Table].Action)=[Forms]!
[AutomobileSearch]![EventList]))
ORDER BY [Automobiles - Main Table].Car, [Automobiles - Main
Table].Mileage DESC;

Jeanette Cunningham
 
D

Dirk Goldgar

If you can't help with my question, please don't respond. Maybe
others can help. This did nothing for me.


This is a very rude response to someone who was trying to help you. You
won't get much help with that attitude. Perhaps you don't realize that no
one is paid to answer questions here.

I've read your original post, and it isn't clear to me what it is you want.
May I suggest that you explain better what you want. Maybe then Ms.
Cunningham -- or someone else who is willing to help you -- will be able to
make a better suggestion.
 
N

nybaseball22

I agree I was rude, and I apologize. I use this newsgroup very often,
have gotten lots of help and could not have done most of what I have
done without the help of the people here that offer their time free of
charge to help. I feel I am very gracious and willing to help others,
however I am not usually in a position to help as I am at best am
amateur. If I could offer an excuse for my rude response, I would,
but it would not justify it.

Jeanette - To you, I apologize. Considering my response and the fact
that you still replied to my response shows you are likely ahead of me
in the "bite your tongue" and forgiveness columns. I again apologize.

Dirk - I know for a fact I have received help from you before. I
appreciate all that help, and I appreciate you calling this to my
attention. It shouldn't need to be pointed out, I should know
better. I apologize to you as well.

If you search my user name, you will see I am almost 100% of the time
on the receiving end of assistance, and I owe everything I have done
with my several projects to each of you who have assisted and taught
me so much along the way. I made a mistake, and it will not happen
again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top