How can I set up a query inside a query?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to narrow a search field down by topic. I have over 200 rows of
information, that fall into 4 topics. For sake of arguement we will say 50
rows each. Of those 50 rows pertaining to topic, they are fall into 4 other
catagories. How can I query the user to pick a topic, then narrow that topic
down further into 4 different catagories? Thanks for whatever help I can get
in advance.

Jay
 
I'm not sure that what you need, try this

Select * From TableName Where [topicFieldName] = [Please Select a topic:]
and [catagoriesFieldName] = [Please select a catagory:]
 
Create a pop-up form named PFrmCriteria and put two option groups on the
form. The first option group named Topics would be the topics and the second
option group named Categories would be the categories. Put the following
code in the Enter event of the second option group to force the user to pick
the topic first:
If IsNull(Me!Topics) Then
Msgbox "Pick A Topic First",,"Topic Not Picked"
Me!Topics.SetFocus
End If

Your query named QryTopicAndCategory then needs to include both the topics
field and categories field. Assuming you have a table for each of these,
that would be TopicID and CategoryID. Put the following in the criteria for
TopicID:
Forms!PFrmCriteria!Topics
Put the folling in the criteria for CategoryID:
Forms!PFrmCriteria!Categories

Finally, put a button on your pop-up form and put the following code in the
Click event of the button:
DoCmd.OpenForm "MyForm"
DoCmd.Close acForm, "PFrmCriteria

Where MyForm is your form for displaying the records and has
QryTopicAndCategory as its recordsource.
 

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

Back
Top