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 / January 2006

Tip: Looking for answers? Try searching our database.

Listbox - limit selection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Snowsride - 31 Jan 2006 14:41 GMT
I have a listbox based on a table and I want the user to be able to either
select the first item which is a * OR make multiple selections from the list.
If the * is selected then the user should not be able to make other
selections.

Thanks
Klatuu - 31 Jan 2006 14:58 GMT
Use the listbox's Change event.  You can tell if the "*" is selected by using
the ListIndex property.  If the selected item is "*", then set the
MultiSelect property to 0.  Now, the trick is, what if a user selects items
other than * first,then goes back and selects the *?

> I have a listbox based on a table and I want the user to be able to either
> select the first item which is a * OR make multiple selections from the list.
>  If the * is selected then the user should not be able to make other
> selections.
>
> Thanks
Douglas J Steele - 31 Jan 2006 18:03 GMT
Sorry, Klatuu, but I don't think that'll work.

From the Help file entry for MultiSelect property "This property can be set
only in form Design view."

I think the only solution is to put logic in the list box's BeforeUpdate
event:

Private Sub MyListbox_BeforeUpdate(Cancel As Integer)
   If Me.MyListbox.ItemsSelected.Count > 1 Then
       If Me.MyListbox.Selected(0) = True Then
           MsgBox "Can't select * with any other values"
           Cancel = True
       End If
   End If
End Sub

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Use the listbox's Change event.  You can tell if the "*" is selected by using
> the ListIndex property.  If the selected item is "*", then set the
[quoted text clipped - 7 lines]
> >
> > Thanks
Klatuu - 31 Jan 2006 18:20 GMT
You are correct, Douglas.  Sorry, I forgot about that.

> Sorry, Klatuu, but I don't think that'll work.
>
[quoted text clipped - 28 lines]
> > >
> > > Thanks
 
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.