Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

List box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pompeyjim - 12 Jun 2007 15:21 GMT
Hi
I’ve got search form (frmsearch) with a list box with several columns and
which has its Multi Select property set to “Extended”. Is there a way the
user can select multiple rows from the list box and have it return the
resulting records to another form (frmMain)?
Ken Sheridan - 12 Jun 2007 19:06 GMT
Add a button to the form with code along these lines in its Click event
procedure.  For this example I've assumed the list box, lstEmployees, is of
employees and the list box's bound column is a numeric EmployeeID:

   Dim varItem As Variant
   Dim strEmployeeIDList As String
   Dim strCriteria As String
   Dim ctrl As Control
   
   Set ctrl = Me.lstEmployees
   
   If ctrl.ItemsSelected.Count > 0 Then
       For Each varItem In ctrl.ItemsSelected
           strEmployeeIDList = strEmployeeIDList & "," &
ctrl.ItemData(varItem)
       Next varItem
       
       ' remove leading comma
       strEmployeeIDList = Mid(strEmployeeIDList, 2)

       strCriteria = "[EmployeeID] In(" & strEmployeeIDList & ")"
       DoCmd.OpenForm "frmMain", WhereCondition:=strCriteria
   Else
       MsgBox "No Employees Selected", vbInformation, "Warning"
   End If

Ken Sheridan
Stafford, England

> Hi
> I’ve got search form (frmsearch) with a list box with several columns and
> which has its Multi Select property set to “Extended”. Is there a way the
> user can select multiple rows from the list box and have it return the
> resulting records to another form (frmMain)?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.