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 / SQL Server / ADP / May 2008

Tip: Looking for answers? Try searching our database.

how to tell if an item selected in listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JEM - 16 May 2008 22:32 GMT
Another question today....In an unbound form, how can I find out if
anything was selected in a listbox?  I want to be able to only fire
some code if something was selected.  I don't need to know which item
was selected at this point, just whether or not something was.
AkAlan - 16 May 2008 22:53 GMT
use the built in len function

IF len(me.cboCombo) > 0 then
    do something
Else
    do something else
End IF

>Another question today....In an unbound form, how can I find out if
>anything was selected in a listbox?  I want to be able to only fire
>some code if something was selected.  I don't need to know which item
>was selected at this point, just whether or not something was.
JEM - 17 May 2008 00:28 GMT
> use the built in len function
>
[quoted text clipped - 11 lines]
> --
> Message posted viahttp://www.accessmonster.com

Thanks, but I don't think that will work with a listbox.
Graham R Seach - 18 May 2008 07:52 GMT
If Not IsNull(Me!Listbox) Then
   MsgBox "Something was selected"
End If

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

> Another question today....In an unbound form, how can I find out if
> anything was selected in a listbox?  I want to be able to only fire
> some code if something was selected.  I don't need to know which item
> was selected at this point, just whether or not something was.
JEM - 18 May 2008 17:05 GMT
On May 18, 2:52 am, "Graham R Seach" <gseach@accessmvp_REMOVE.com>
wrote:
> If Not IsNull(Me!Listbox) Then
>     MsgBox "Something was selected"
[quoted text clipped - 11 lines]
>
> - Show quoted text -

Thanks, i wish it was that simple, but it doesn't work. Even with
items selected it still sees it as Null. I also tried:

    If not isnull(me.listbox.ItemsSelected) then
             'do something
    end if

Other ideas?
JEM - 18 May 2008 17:11 GMT
> On May 18, 2:52 am, "Graham R Seach" <gseach@accessmvp_REMOVE.com>
> wrote:
[quoted text clipped - 29 lines]
>
> - Show quoted text -

Duh!  Here it is:

If me.listbox.ItemsSelected.Count > 0 then
 'do something
End if
Graham R Seach - 19 May 2008 02:29 GMT
>>...i wish it was that simple...
It is that simple, but I assumed you had MultiSelect = No. My mistake!

By the way, ItemsSelected.Count won't work when MultiSelect = No and testing
occurs in the listbox's Click event.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

On May 18, 2:52 am, "Graham R Seach" <gseach@accessmvp_REMOVE.com>
wrote:
> If Not IsNull(Me!Listbox) Then
> MsgBox "Something was selected"
[quoted text clipped - 16 lines]
>
> - Show quoted text -

Thanks, i wish it was that simple, but it doesn't work. Even with
items selected it still sees it as Null. I also tried:

    If not isnull(me.listbox.ItemsSelected) then
             'do something
    end if

Other ideas?
 
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.