list box double click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew

    #1

    list box double click

    Access 2000: I'm showing a few rows in a list box and trap
    double-clicks. how can I determin which row the user double clicked
    on? Any help appreciated.
  • Pieter Linden

    #2
    Re: list box double click

    matthew@yellowm arker.co.uk (Matthew) wrote in message news:<51c50e12. 0310200129.3b23 af53@posting.go ogle.com>...[color=blue]
    > Access 2000: I'm showing a few rows in a list box and trap
    > double-clicks. how can I determin which row the user double clicked
    > on? Any help appreciated.[/color]

    You use the ItemsSelected collection of the listbox.

    '************** ****** Code Start *************** *********
    Dim frm As Form, ctl As Control
    Dim varItem As Variant
    Dim strSQL As String
    Set frm = Form!frmMyForm
    Set ctl = frm!lbMultiSele ctListbox
    strSQL = "Select * from Employees where [EmpID]="
    'Assuming long [EmpID] is the bound field in lb
    'enumerate selected items and
    'concatenate to strSQL
    For Each varItem In ctl.ItemsSelect ed
    strSQL = strSQL & ctl.ItemData(va rItem) & " OR [EmpID]="
    Next varItem

    'Trim the end of strSQL
    strSQL=left$(st rSQL,len(strSQL )-12))
    '************** ****** Code end *************** *********

    This is from www.mvps.org/access (so you know it works!) Basically,
    you're iterating through the ItemsSelected collection and appending
    the values to a string variable.

    HTH

    Comment

    Working...