Solved

Find unselected listbox value

Posted on 2006-07-04
6
680 Views
Last Modified: 2008-02-01
Hi,

I am trying to automatically get the value of an unselected and unbound listbox in my form. I need to get this value to determine what happens next in my code. My listbox is called RatingFind.

I have also tried to change my listbox to a combo box to try to get the value from this, but I can't figure out how to select this value either!

Can anyone suggest any code that I can use to get this value from my listbox?

Thanks in advance,
Susan
0
Comment
Question by:Susan2c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Expert Comment

by:Carl2002
ID: 17035651
Do you mean you want the values of anything unselected from the listbox?
ir if the list box contains 1,2,3,4,5 and 4 is selected you want to return 1,2,3 and 5?

Carl.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17035654
Hi Susan2c,
If nothing is selected in the list box then it will be null.

Otherwise if the code is in the form's module you would use something like:

if me.ratingfind = somevalue then

The value of a single-select list box, or a combo box is the value in the bound column of the row selected.  The bound column might not be the value that is displayed to the user.

Pete
0
 

Author Comment

by:Susan2c
ID: 17035725
The list box is unbound and it will only contain one value, if it has a value in it. The value will either be 1 or null. I don't want the user to have to select a list box for no reason, so I want to read it unselected. I know there is some code to do this, and I have tried to use the following, but it will only return null so far!

Me!RatingFind.Selected(1) = True
vartest8 = Me.RatingFind.Value
MsgBox vartest8

Thanks,
Susan
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 65

Accepted Solution

by:
rockiroads earned 125 total points
ID: 17035748
U can use ListCount

if Me.RatingFind.ListCount = 0 then
    msgbox "No Items"
else
    msgbox "First Item = " & Me.RatingFind.Column(0, 0)
end if
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17035770
So are you saying that if it is null you will treat it as if it is 1?
If so, why are you testing it - and moreover, why does it exist at all?

Pete
0
 

Author Comment

by:Susan2c
ID: 17035866
Thanks rockiroads, that has worked.

Pete, there is either a value of 1, or it is null, and I wanted to test if there was a value there.

Thanks again,
Susan
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question