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

    How to multi select items from multi boxes

    Hi Experts
    I have two boxes and using them separate for opening the report.
    Now I want to open the report to select from the twice boxes but I am unable to understand how to select them.
    The code is given under:

    If Me.Category_Case_Criminal.ItemsSelected.Count = 0 Then
    MsgBox "Please Select atleast One Item"
    Exit Sub
    End If
    'add selected values to string
    Set ctl = Me.Category_Case_Criminal
    For Each varItem In ctl.ItemsSelected
    'strWhere = strWhere & ctl.ItemData(varItem) & ","
    strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
    Next varItem
    'trim trailing comma
    strWhere = Left(strWhere, Len(strWhere) - 1)


    If Me.Category_Case_Criminal.ItemsSelected.Count = 0 Then


    There is problem I want to add two boxes here: the second is under:
    If Me.Category_Case_Civil.ItemsSelected.Count = 0 Then
    If I code it as: If Me.Category_Case_Criminal.ItemsSelected.Count = 0 & If Me.Category_Case_Civil.ItemsSelected.Count = 0 Then its give error
    I don't understand what to write instead of Then so it may select the twice boxes at once
    How can I select from two boxes so it may open the report containing twice result.
    The report is already generated by innerjoin query:
    The Screen short is under:
    Click image for larger version. 

Name:	problem.jpg 
Views:	17 
Size:	52.7 KB 
ID:	42326
    Last edited by ijaz8883; 07-01-2020 at 03:33 AM. Reason: explain

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Try:
    If Me.Category_Case_Criminal.ItemsSelected.Count = 0 AND Me.Category_Case_Civil.ItemsSelected.Count = 0 Then
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ijaz8883 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    103
    Quote Originally Posted by Bob Fitz View Post
    Try:
    If Me.Category_Case_Criminal.ItemsSelected.Count = 0 AND Me.Category_Case_Civil.ItemsSelected.Count = 0 Then
    Thanks a Lot its worked for the said statement. The error was onward and its resolved.
    I was using the same formula AND for next combining the statement but when I tried many times different ways the problem resolved:
    Set ctl = Me.Category_Case_Criminal
    For Each varItem In ctl.ItemsSelected
    I have to set the statement separately for and its solve my problem
    Thanks a lot

    Last edited by ijaz8883; 07-01-2020 at 05:37 AM. Reason: Error Resolved

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

Similar Threads

  1. Replies: 2
    Last Post: 05-21-2014, 01:16 PM
  2. Replies: 12
    Last Post: 01-08-2014, 05:15 PM
  3. Selecting items in multi-select list box
    By chronister in forum Access
    Replies: 3
    Last Post: 08-25-2013, 03:33 AM
  4. Multi Select Check Boxes?
    By CDavis10 in forum Forms
    Replies: 2
    Last Post: 07-19-2013, 07:04 AM
  5. Multi-select List Boxes
    By Rawb in forum Programming
    Replies: 6
    Last Post: 09-21-2010, 09:02 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