Unanswered: Create a Report base on Listbox selection
I am trying to create a report based on the selection(s) from a listbox (on a form) using visual basic. I have searched the forum and tried some of the code available but: nothing is working so far. The code I was using does print the column names but no data on the report.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim myList As Control
Dim x As Integer, Strg As String
Set myList = Forms!myForm!myList
For x = 0 To myList.ListCount
Strg = Strg & myList.ItemData(x) & vbCrLf
'Here, the DisplaytextBox control is located in the Detail section
'and the controls 'CanGrow' property set to TRUE.
Me.DisplayTextBox = Strg
What am I doing wrong? Is there a better way to do this?
I have to produce a nuber of reports in using a combo as the "selector".
However, I use the humble query, that way ill have less to do and besides I'm awful at sql and vb.
But I use a query to populate the report simply by placing the Like[formname].[comboname] and have button set to open the report once the critera has been picked you could of course use the afterupdate to run a macro to open the report
I know its not quite the stuff you are looking for but here is MS answer to every report in your database. (I have remove 2 of there lines of code ) I used this last week to populate a listbox, so I know every report in my database..
You could use this to populate your listbox with every report ?
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
For Each obj In dbs.AllReports
Debug.Print obj.Name 'change this bit to additem to your listbox..
I'm still trying to understand your initial problem.
I have a form that has a listbox on it, in the listbox are the field names from a table. When the user selects the field name(s), I want to execute a report base on the field name(s) selected. This report will only pull back records base on the username. When the report is opened, it will contain only the fields selected (from the listbox) and the data for that field.