Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to clear the chosen items (Access 2000)

    I have a list box from where i choose the products and open the report.My list box is called lstProducts. On opening the report i want to clear the chosen products with the line: Me!lstProducts.Value = 0
    however it seems not to work. On closing the report the chosen products stay on and it follows that i coulnd clear the list box.Why is it so and how could i clear the list box ?


    Private Sub FrameCategory_Click()
    Dim varItem As Variant
    Dim intAnswer As Integer
    intAnswer = MsgBox(" Print? ", vbQuestion + vbYesNo)
    Dim strWhere As String
    For Each varItem In Me.lstProducts.ItemsSelected
    strWhere = strWhere & ", " & Me.lstProducts.ItemData(varItem)
    Next
    If Not strWhere = "" Then
    strWhere = Mid(strWhere, 3)
    strWhere = "ProductID in (" & strWhere & ")"
    End If
    If intAnswer = vbNo Then
    DoCmd.OpenReport "RptPriceList", acViewPreview, , strWhere
    Else
    DoCmd.PrintOut acPages, 1, 1, , 1
    DoCmd.Close acReport, "RptPriceList", acSaveNo
    End If

    Me!lstProducts.Value = 0
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: how to clear the chosen items (Access 2000)

    You can use code like this:

    Dim i As Integer
    For i = 0 To Me.lstProducts.ListCount - 1
    Me.lstProducts.Selected(i) = False
    Next i

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •