Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    May 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count of list box (97)

    I know I have done this before but I can't remember how. I have a form with a list box that shows who is logged on. If there are more than one person I want a certain form to open. How do I do a count on the list box?
    if list box count > 1 then
    action
    else
    no action
    end if

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

    Re: Count of list box (97)

    The listbox has a ListCount property:

    If lbxUsers.ListCount > 1 then
    ...
    Else
    ...
    End If

    As an alternative, you could use the row source of the list box:

    Dim rst As RecordSet
    Set rst = CurrentDb.OpenRecordset(lbxUsers.RowSource, dbOpenDynaset)
    rst.MoveLast
    If rst.RecordCount > 1 Then
    ...
    Else
    ...
    End If
    rst.Close
    Set rst = Nothing

Posting Permissions

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