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 / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Multiple selections from a list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Smiley - 20 Jun 2007 19:49 GMT
Hi,

Can I do multiple selection from a list. What I want to achieve is this, I
have a list of items which users would select. I would have either check box
or radio buttom beside each items so that user would just check the items
they want and this will be printed out on a report and display on a enquiry
form.
Scott McDaniel - 20 Jun 2007 20:33 GMT
>Hi,
>
[quoted text clipped - 3 lines]
>they want and this will be printed out on a report and display on a enquiry
>form.

You can put as many Radio Buttons or Checkboxes as you want on a form (up to the internal limit, that is) and use that
to build your report.

You can't, have a Listbox that shows checkboxes or radiobuttons, however. A Listbox does allow Multiple selections, but
it simply highlights each line that's selected ...

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
John W. Vinson - 21 Jun 2007 00:44 GMT
>Hi,
>
[quoted text clipped - 3 lines]
>they want and this will be printed out on a report and display on a enquiry
>form.

You can use VBA code from a Multiselect listbox. HEre's some sample code that
you'll need to adapt.

Private Sub cmdProcess_Click()
   ' Comments  : Update the AnimalCondition table based on the selections in
   '             the unbound multiselect listbox lstHealthIssues.
   '             Newly selected rows will be added to the table, newly
cleared
   '             rows will be deleted.
   ' Parameters: None
   ' Modified  : 01/29/02 by JWV
   '
   ' --------------------------------------------------
   ' Populate the AnimalCondition table with the selected issues
   On Error GoTo PROC_ERR
       
   Dim iItem As Integer
   Dim lngCondition As Long
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   
   ' save the current record if it's not saved
   If Me.Dirty = True Then
       Me.Dirty = False
   End If
   Set db = CurrentDb
   ' Open a Recordset based on the table
   Set rs = db.OpenRecordset("AnimalCondition", dbOpenDynaset)
   With Me!lstHealthIssues
       ' Loop through all rows in the Listbox
       For iItem = 0 To .ListCount - 1
           lngCondition = .Column(0, iItem)
           ' Determine whether this AnimalID-HealthID combination is
currently
           ' in the table
           rs.FindFirst "[AnimalID] = " & Me.AnimalID & " AND " _
                        & "[HealthIssueID] = " & lngCondition
           If rs.NoMatch Then ' this item has not been added
               If .Selected(iItem) Then
                   ' add it
                   rs.AddNew
                   rs!AnimalID = Me.AnimalID
                   rs!HealthIssueID = lngCondition
                   rs.Update
               End If ' if it wasn't selected, ignore it
           Else
               If Not .Selected(iItem) Then
                   ' delete this record if it's been deselected
                   rs.Delete
               End If ' if it was selected, leave it alone
           End If
       Next iItem
   End With
   rs.Close
   Set rs = Nothing
   Set db = Nothing
   Me.subAnimalCondition.Requery
   
PROC_EXIT:
   Exit Sub
   
PROC_ERR:
   MsgBox "Error " & Err.Number & " in cmdProcess_Click:" _
          & vbCrLf & Err.Description
   Resume PROC_EXIT
   
End Sub

            John W. Vinson [MVP]
Smiley - 21 Jun 2007 13:18 GMT
Many thanks everyone. I shall try it out so it might be some days before I
get back to give you all an update.

Have a good day,

>>Hi,
>>
[quoted text clipped - 77 lines]
>
>             John W. Vinson [MVP]
 
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.