UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Reports Should Display From Multiple Items Selected From The Combo Box, Access 2016    
 
   
amy
post Feb 11 2019, 03:32 PM
Post#1



Posts: 67
Joined: 16-April 18



Hi all,
I am trying to get reports which displays data with multiple item selected from the combo box.
Right now my reports displays for 1 particular item selected from the combo box.
When we select multiple items from combo box, the reports should show for the all item selected from the combo box.
I have no guess how to make multiple items select to...and then make the reports to display for the same.
Can anyone help me how to start with...

Thanks
Amy

Attached File(s)
Attached File  WeeklyReportsByOrderNumber.zip ( 168.94K )Number of downloads: 3
 
Go to the top of the page
 
MadPiet
post Feb 11 2019, 03:52 PM
Post#2



Posts: 2,828
Joined: 27-February 09



use a multi-select listbox. There's an example at http://www.theaccessweb.com/reports/rpt0005.htm
Go to the top of the page
 
amy
post Feb 12 2019, 02:46 PM
Post#3



Posts: 67
Joined: 16-April 18



@Madpiet...
I am not fully understanding this...Can you please help me how to start with...

Thanks
Go to the top of the page
 
Dan Dungan
post Feb 12 2019, 03:40 PM
Post#4



Posts: 297
Joined: 20-July 10
From: chatsworth, ca


MadPiet doesn't seem to be around right now. Maybe I can help.

Try these steps:

Create form to open the report.
Put a command button on the form.
Put the below code in the command button's click event.

CODE
Private Sub btnTestQuery_Click()
Dim vItm As Variant
Dim stWhat As String
Dim stCriteria As String
Dim stSQL As String
Dim loqd As QueryDef

    stWhat = "":    stCriteria = ","
    For Each vItm In Me!mslbxTest.ItemsSelected
        stWhat = stWhat & Me!mslbxTest.ItemData(vItm)
        stWhat = stWhat & stCriteria
    Next vItm
    Me!txtCriteria = CStr(left$(stWhat, Len(stWhat) - Len(stCriteria)))
    Set loqd = CurrentDb.QueryDefs("qryMultiSelTest")
    stSQL = "SELECT EmployeeID, LastName, FirstName, TitleOfCourtesy, "
    stSQL = stSQL & "Title FROM Employees WHERE EmployeeID"
    stSQL = stSQL & " IN (" & Me!txtCriteria & ")"
    loqd.SQL = stSQL
    loqd.Close
    DoCmd.OpenQuery "qryMultiSelTest"
'add
   doCmd.OpenReport "your report name"
End Sub


Set the record source of the report to qryMultiSelTest.

I didn't test any of this.
This post has been edited by Dan Dungan: Feb 12 2019, 04:07 PM

--------------------
Dan
Go to the top of the page
 
MadPiet
post Feb 12 2019, 04:25 PM
Post#5



Posts: 2,828
Joined: 27-February 09



(Anybody that wants to contribute is more than welcome!)

One of the limitations of a combobox is that it only allows you to select one value at a time. if you want to select multiple values, you would have to use a Listbox and set the Multi-Select property to "Extended".

Okay... took me a while, because I was treating order number like a number... LOL. I guess the reason you're having trouble with this is that you need to know how to play with VBA to do it, so I did it for you. Basically, you build the filter string in code (as a comma-separated list) and then use IN() and stuff that list inside that and pass that as the filter.
Attached File(s)
Attached File  WeeklyReportsByOrderNumber.zip ( 165.6K )Number of downloads: 3
 
Go to the top of the page
 
amy
post Feb 13 2019, 08:14 AM
Post#6



Posts: 67
Joined: 16-April 18



Thank you very much Madpiet..I will try this in my current database.

Thanks
Amy
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    22nd February 2019 - 10:32 AM