Using Form to retrieve Queries

L

lordjeffj

Hello,

I have a switch board that has a list of name that is assoicate with queries
and reports. I would like to retreive those queries and report for a list box
in the form, from a macro or VBA. Please give direction or help.

Thank You,
Jeffrey
 
B

Barry Gilbert

Assuming a listBox called List0, use this code:

Dim rptThis As AccessObject
Dim qryThis As DAO.QueryDef
Dim strList As String
Me.List0.RowSourceType = "Value List"
For Each rptThis In CurrentProject.AllReports
strList = strList & rptThis.Name & ","
Next
For Each qryThis In CurrentDb.QueryDefs
strList = strList & qryThis.Name & ","
Next
Me.List0.RowSource = strList

Barry
 

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