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 / Modules / DAO / VBA / March 2007

Tip: Looking for answers? Try searching our database.

Multiselect restrict to one if "none" selected

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Karl H - 02 Mar 2007 07:10 GMT
Hi,
I have a multiselect box that has a number of choices, one of which is "None"
I would like to program the box to trigger a  Msgbox if "None" is selected
in addition to other choices, as they are incompatible.

One option would be to leave "none" as the default text box data, but I
don't want to do that.

I'm thinking something like:
If strselected (some parse = "None")& not "" Then
msgbox "Cannot have 'None' and other selections--must deselect one"

My current code for the box so far is:

'taking selected limits to txtLimitsfrmlbx
Private Sub lbxLimits_LostFocus()
Dim strSelected As String
Dim varSelected As Variant

 For Each varSelected In Me.lbxLimits.ItemsSelected
   strSelected = strSelected & _
     Me.lbxLimits.Column(1, varSelected) & vbCrLf
 Next varSelected
   txtLimitsFrmlbx.SetFocus
   txtLimitsFrmlbx.Text = strSelected
   End Sub

Thank you for any ideas,
Karl
Alex Dybenko - 02 Mar 2007 10:07 GMT
Hi,
try this:

if instr(1,strSelected,"None") >0 and ubound(split(strSelected,vbCrLf)) >0
then
...

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hi,
> I have a multiselect box that has a number of choices, one of which is
[quoted text clipped - 26 lines]
> Thank you for any ideas,
> Karl
Karl H - 02 Mar 2007 17:36 GMT
Hi Alex, thank you for responding. Trying the code, it brings up the MsgBox
when "None" is selected by itself, and that should be an acceptable response.
How should I change it the code?
Thank you very much,
Karl

> Hi,
> try this:
[quoted text clipped - 33 lines]
> > Thank you for any ideas,
> > Karl
Karl H - 02 Mar 2007 22:51 GMT
Hi again,
I changed your last code to: ....ubound(split(strSelected,vbCrLf)) >1
and that took care of the glitch with "none" triggering the message box.
Thank you, again, it was very helpful,
Karl

> Hi,
> try this:
[quoted text clipped - 33 lines]
> > Thank you for any ideas,
> > Karl
 
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.