Results 1 to 7 of 7
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Multi Select

    I have this code: Gleaned earlier from here by June7 assistance for an earlier request. I adapted it for another form/output and it will not select.


    Code:
    Private Sub Select_Changes_Click()
        Dim strWhere As String
        Dim ctl As Control
        Dim varItem As Variant
        Set ctl = Me.My_CR_Number
    If Me.My_CR_Number.ItemsSelected.Count = 0 Then
         MsgBox "Nothing was selected"
            Exit Sub
        End If
    For Each varItem In ctl.ItemsSelected
       strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
    Next varItem
       strWhere = Left(strWhere, Len(strWhere) - 1)
       DoCmd.OpenReport "Select Changes", acViewReport, , "CR_Numbers IN(" & strWhere & ")"
       DoCmd.Close acForm, "Select Changes"
    End Sub
    From [Select Changes] Query
    Code:
    SELECT Chng_ReqQry.CR_Numbers
    FROM Chng_ReqQry
    GROUP BY Chng_ReqQry.CR_Numbers, Chng_ReqQry.CR_ID, Chng_ReqQry.CR_No
    HAVING (((Chng_ReqQry.CR_No)<>0))
    ORDER BY Chng_ReqQry.CR_ID;
    Into a report [Select Changes] report.

    Gathering information from:
    CR_Numbers: Format(([Change Request].[CR_No]+([Sub_No]*0.01)),"Fixed")




    Where am I going wrong?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The code for Sub Select_Changes_Click() works, as far as I can tell.

    Where am I going wrong?
    Hard to tell. You didn't state the problem.
    What is the error?
    What is "wrong"?

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Quote Originally Posted by ssanfu View Post
    The code for Sub Select_Changes_Click() works, as far as I can tell.


    Hard to tell. You didn't state the problem.
    What is the error?
    What is "wrong"?
    When the [Select Changes] Form opens, I cannot select anything. If I click on the select button, I get the desired POPup saying nothing was selected. I was thinking it may be from the Dim strWhere As String is using what was originally a number. But CR_Numbers formatting changes it to a text, and I tried it with a text field also by changing the
    DoCmd.OpenReport "Select Changes", acViewReport, , "CR_Numbers IN(" & strWhere & ")" CR_Numbers into [Levels] A text based field

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So the query returns all records and the code creates a filter string to use when opening the report.

    If you open just the query "Select Changes", are any records returned?
    (shouldn't use spaces in object names, BTW)

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    I know I shouldn't use spaces. Bad habit. I get all the records returned in the Select Changes Query, If I run the Select Changes Report It will report all the records.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, the query is returning records and the report displays them.

    Now to determine if the criteria should be a string or a number.

    In design view of the query, in the criteria row, enter a "CR_Numbers" in quotes and run the query. Is just that "CR_Numbers" returned?
    If no records are returned, try the criteria without quotes.

  7. #7
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    ssanfu,
    I fiqured out the issue. I had it in a type of loop where it was getting the CR_Numbers from the same Qry as I was intending to base the report on. Once I changed it to another query for the CR_Numbers it worked.

    Thanks

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

Similar Threads

  1. Multi Select List box
    By Thompyt in forum Programming
    Replies: 9
    Last Post: 10-05-2015, 01:15 PM
  2. Multi-select checkbox
    By Access_Novice in forum Forms
    Replies: 1
    Last Post: 01-08-2014, 01:44 AM
  3. multi select list box
    By crowegreg in forum Forms
    Replies: 1
    Last Post: 07-28-2012, 11:52 PM
  4. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  5. Multi Select Box in Form
    By SJ85 in forum Forms
    Replies: 1
    Last Post: 04-12-2012, 01:25 PM

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