Results 1 to 2 of 2

Thread: List boxes

  1. #1
    Join Date
    May 2002

    Unanswered: List boxes

    I have a form that allows my users to select customers to apply a query against. This form utillizes a listbox (lbCusts) with 2 columns (0 - cust No (not visible; bound) and 1 - CustName (visible; not bound))I have the multi-select proiperty enabled allowing for the ability to select multi-customers. I have a textbox (txtCusts) that when the user selects customer(s), it populates all of the selections (as a string) into this text box. This works fine. However, I would like to have default setting that all customers be selected. I will do this by having a checkbox on the form (chkCustomers). When this is positive, all customers are selected, unchecked - all are not checked, allowing user to individually select customers. I am assuming that on 'on-click' property of this check box, it should run a routine that first determines if it is true or false and then correctly selects all or de-selects all. What code can I use to make the determination and then select/de-select all. Thanks

  2. #2
    Join Date
    Jul 2001
    Add the following code to the 'OnClick' event of your checkbox:

    Private Sub chkCustomers_Click()
    Dim frm As Form
    Dim ctl As Control
    Dim intCurrentRow As Integer

    Set frm = Me
    Set ctl = frm!lbCusts

    If Me.chkCustomers = True Then
    For intCurrentRow = 0 To ctl.ListCount - 1
    ctl.Selected(intCurrentRow) = True
    Next intCurrentRow
    For intCurrentRow = 0 To ctl.ListCount - 1
    ctl.Selected(intCurrentRow) = False
    Next intCurrentRow
    End If

    End Sub

Posting Permissions

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