Results 1 to 11 of 11
  1. #1
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103

    Multi Select List Box to open specific select Data Report


    Hi Experts
    I have a database and I have a Form where I have put a button with list box to select the data and open the report
    But I am facing problem to sort out the data It does not sort the data and give the error of parameter but I want to open with a single parameter without entering the para meter
    The DB samplesample.zip is also attached so that you may understand my problem.


    Click image for larger version. 

Name:	2.jpg 
Views:	29 
Size:	25.4 KB 
ID:	40018
    Click image for larger version. 

Name:	3.jpg 
Views:	29 
Size:	122.9 KB 
ID:	40019

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    don't use multi select list...they require programming. Instead, use a regular list box and dbl-click item to add to a 'picked' table.
    then use the tPicked table to join to the table and only pull those items.
    No programming.

    Click image for larger version. 

Name:	pick state lbls.png 
Views:	29 
Size:	27.7 KB 
ID:	40020

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That code looks familiar. You need delimiters because your value is text:

    strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"

    resolves your error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by pbaldy View Post
    That code looks familiar. You need delimiters because your value is text:

    strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"

    resolves your error.
    Mr. pbaldy
    your code worked on Pending based query and button. But still a problem facing that its does not filter the data by selecting the Point No.1 or Point No.2 or Point No.3 in report but it shows all the data including unselected point in report.
    And can I add a button to select All and Deselect All below this list box?

  5. #5
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by ranman256 View Post
    don't use multi select list...they require programming. Instead, use a regular list box and dbl-click item to add to a 'picked' table.
    then use the tPicked table to join to the table and only pull those items.
    No programming.

    Click image for larger version. 

Name:	pick state lbls.png 
Views:	29 
Size:	27.7 KB 
ID:	40020
    Mr. ranman256
    Can you provide me the sample of this DB. It may also solve my problem but I don't understand how to do this because I am not expert in Access.
    The above said Code i used is also theft from a website DB and amend it as I required.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check the field you have in the code plus the values returned in the listbox. I think it's the wrong field and the value in the bound column of the list listbox was "pending" if memory serves.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by pbaldy View Post
    Check the field you have in the code plus the values returned in the listbox. I think it's the wrong field and the value in the bound column of the list listbox was "pending" if memory serves.
    No Sorry: I just want the list of Points in List box and the Status Pending/Decided/Transfer in query not in selection suggestion.

    Sorry I don't understand. Now Just to Filter the Point (Point No.1/Point No.2/Point No.3) is remaining here and every thing is complete.
    Let me know what to do here

  8. #8
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by pbaldy View Post
    Check the field you have in the code plus the values returned in the listbox. I think it's the wrong field and the value in the bound column of the list listbox was "pending" if memory serves.
    Oh Yes Thanks a lot:
    I Got it with some alteration! I just change in List Box Query: Where there was Status I finished it and write the same as other
    Attachment 40028
    It was just an Idea and its work: But may be its make any problem afterword but at this time its working perfect.
    and also change just one word in code "Point"
    DoCmd.OpenReport "Testreport", acPreview, , "Points IN(" & strWhere & ")"
    Now its working
    Thanks you Mr. pbadly
    I am also waiting the DB of Mr.
    ranman256 it would also better for me for multiple choice
    I am marking your answer as reputation
    Select or clear button are also done.


  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That attachment doesn't work for me. In the original, the listbox bound column was Status, which it sounds like you caught. The second was in your VBA code:

    DoCmd.OpenReport "Testreport", acPreview, , "Status IN(" & strWhere & ")"

    which referred to Status instead of Points.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by pbaldy View Post
    That attachment doesn't work for me. In the original, the listbox bound column was Status, which it sounds like you caught. The second was in your VBA code:

    DoCmd.OpenReport "Testreport", acPreview, , "Status IN(" & strWhere & ")"

    which referred to Status instead of Points.
    Sorry I think there may be problem in my attached file
    The Updated and Complete Working File is attached
    Lets check it. May be I have no need to enter an extra field in query by changing in code.

    sample Completed.zipsample Completed.zip

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could have just selected the Points field:

    SELECT DISTINCT TestQuery.Points
    FROM TestQuery;

    You just would have needed to change the column count and column widths properties of the listbox accordingly. You could also have referred to the second column of the listbox:

    ctl.Column(1, varItem)

    1 is the second column as the column property is zero based. In your case I'd have done the first for simplicity.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open report from multi-select list box
    By Nadine67 in forum Access
    Replies: 1
    Last Post: 07-22-2015, 06:01 PM
  2. Replies: 5
    Last Post: 12-26-2013, 02:19 PM
  3. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  4. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums