• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

Find unselected listbox value

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
Susan2c
Asked:
Susan2c
1 Solution
 
Carl2002Commented:
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
 
peter57rCommented:
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
 
Susan2cAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
rockiroadsCommented:
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
 
peter57rCommented:
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
 
Susan2cAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now