There are three ways of creating a query. The query wizard, which you've
used, is at one end of the "easy/hard" scale. At the other is writing the
"SQL" code by hand in SQL view (often a good idea to view the SQL however
you create your query.) In the middle is the query designer, and it sounds
like that's where you ought to be working now.
This website gives you an introduction to queries including the designer:
http://office.microsoft.com/trainin...ID=RC102919041033&CTT=6&Origin=RC102919041033
(may wrap lines, re-join with no spaces).
If you open the designer, you first have to add tables. Try adding just
one. Drag a few fields onto the matrix, and view the results. Try adding a
sort value (ascending or descending) and take it away again. Try adding a
criterion: if you want names that begin with a P, then put into the
Criterion row, under the appropriate field:
Like "P*"
Then take it out again - just practice.
Then add one more table. I'm assuming here that your tables are right, and
that there is at least one relationship (typically where records in one
table contain a "key" reference to records in another. That's a pretty big
assumption, of course.
Add tables so that you have both sides of one of your relations. If you've
set up the relationship in the Relationships window, then the query designer
will pick that up; otherwise you have to drag the appropriate field from one
table to the other in the view at the top of the query designer.
You'll only get those records where there's a match. So, if you have tables
for Customer and for Order, where one customer may place many orders, you'd
typically include the customerID (the customer "key") in each Order record
(as a "foreign key"). You may be interested in orders from customers whose
name begins with P, so you've added the criterion mentioned above. But if
no customers whose name begins with a P has placed an order, you'll
(rightly!) get no results. It's worth mentioning that you can change the
properties of the relationship so that it lists all customers and their
orders, including those with none. Double-click the relationship line to
see how to do this (it's called an Outer Join as opposed to the normal Inner
Join).
When I'm having trouble with a query, I build it up in the designer by
stages. I list one table, and then another, adding fields one at a time so
I can see what records I'm getting. If you're unfamiliar with the query
designer, open an existing query in Design View - the designer is what comes
up Copy an existing query, and then fool about with the copy in the
designer to see what you can do.
If you still end up stuck, view your query in SQL View. Copy the text you
see there, and post it here.
HTH
Phil, London