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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Results of a Query viewed in a list box?

Status
Not open for further replies.

lexis7

Programmer
Sep 23, 2002
26
US
I have a list box with many different values in it. I have the users select a value and click "Search"

This pulls up the information behind that selected value. I did this through a select query.

What i want to happen is to view this information in another list box on the bottom of the form. Right now the query just comes up in Datasheet view.

Any help fast would be great!!!!!!!!

The code I'm using is below:

Private Sub cmdSearch_Click()
Select Case Me!fraSearch
Case 1
DoCmd.OpenQuery "SearchType"

Case 2
DoCmd.OpenQuery "Search Site"
End Select

End Sub
 
From your code, I'll assume that the two queries bring back different data sets.

OK - from there - you can take several approaches -
A quick and easy one is to just drop a list box on the window and put it where you want to display the information and link it to the appropriate query through the list box wizard.

Now - in your code:
Select Case Me!fraSearch
Case 1
lst.SearchType.Requery
lstSearchType.visible = true
lst.SearchSite.visible = False
'comment out DoCmd.OpenQuery "SearchType"
Case 2
'comment out DoCmd.OpenQuery "Search Site"
lst.SearchSite.Requery
lst.SearchType.Visible = False
lst.SearchSite.Visible = True

End Select

What this does is let you have two list boxes in the same space with only the correct one displayed when you need it. You'll need to decide for your app if one should be visible when the form comes up or if they should both be invisible.

If you want access to the data in both queries at the same time - try dropping a tab control on the form - and the list boxes on separate tabs.

Hope it helps.
 
We must think alike... I did this moments before your post. Thanks for your help!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top