?
Solved

List Box to run multiple queries

Posted on 2004-11-18
5
Medium Priority
?
222 Views
Last Modified: 2010-05-18
My question is a bit confusing, but I will try to explain. I have a list box (called "LstAvailQry" and muli-select is enabled to SIMPLE). The list displays several rows of data showing my available queries.  For example:
Query      Description
Query1    Show all employees Name and Address
Query2   [Show number of referrals by shift]
Query3    Show number of declined referrals by shift
Query4   [Show list of referrals closed by employee]

I want the user to be able to select multiple rows of data and click on a run button. The run button will then run all queries selected.  For example, if I select Queries 2 & 4, the application will run these two queries for me to view.

As I saw some samples in previous question and I believe they use the loop function, but I am not sure how to do that in my case.

Could you kindly provide some code that will run these queries?
 

Thanks
0
Comment
Question by:epicazo
  • 2
  • 2
5 Comments
 
LVL 58

Accepted Solution

by:
harfang earned 1000 total points
ID: 12615630
Private Sub cmdRun_Click()

    Dim varItem

    For Each varItem In lstAvailQry.ItemsSelected
        Docmd.OpenQuery lstAvailQry.ItemDate(varItem)
    Next varItem

End Sub
0
 

Author Comment

by:epicazo
ID: 12615707
I get an error, method or data member not found... lstAvailQry.ItemDate(varItem)
0
 

Author Comment

by:epicazo
ID: 12615725
it was just a typo on itemdata().

     Docmd.OpenQuery lstAvailQry.ItemData(varItem)

 I corrected it -- thank you so much.
0
 
LVL 4

Expert Comment

by:dan_vella
ID: 12615764
In case that doesn't work:


For Each qry In Me.LstAvailQry.ItemsSelected
DoCmd.OpenQuery qry
Next
0
 
LVL 58

Expert Comment

by:harfang
ID: 12615844
:)
My fingers often confuse "date" and "data"... good job!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question