Connecting Tech Pros Worldwide Forums | Help | Site Map

list box values

Site Addict
 
Join Date: Feb 2007
Posts: 553
#1: Jul 10 '07
Hi

I have 2 tick boxes (say A and B) and a list box. I want following, can anyone help

If tick-box A is checked: the list box will show all of its values

If tick-box B is checked: the list box will show only the first 2 values

I know how to write code for tick-boxes, please give help on doing the List Box

thanks

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: Jul 10 '07

re: list box values


You'll want to change the list box's rowsource property from the on click event of the check box.
Site Addict
 
Join Date: Feb 2007
Posts: 553
#3: Jul 10 '07

re: list box values


Rabbit

It wont be very useful in this case

Is there no way just to disable or to make invisible any of the value in the List box ??


Quote:

Originally Posted by Rabbit

You'll want to change the list box's rowsource property from the on click event of the check box.

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#4: Jul 10 '07

re: list box values


Quote:

Originally Posted by questionit

Rabbit

It wont be very useful in this case

Is there no way just to disable or to make invisible any of the value in the List box ??

Only if it's a Value List, then you can use Me.ListboxName.RemoveItem()
If it's Table/Query, you'll need to change the Row Source. They both have the same aesthetic effect.
Site Addict
 
Join Date: Feb 2007
Posts: 553
#5: Jul 10 '07

re: list box values


Ok, but i have a problem with doing Rwresouce. See my code (it works OK but there is another problem):

Me.lst_Heating_Choice.RowSourceType = "Table/Query"
Me.lst_Heating_Choice.RowSource = "SELECT Heating_Choice_Index, Heating_Choice_Description FROM test WHERE Heating_Choice_Index=5
Me.lst_Heating_Choice.Requery

Since my List Box is setup to take upto 5 values and on the 5th value i have an condition written up for doing some other things as well.

When i run the above query, i am now getting only 1 value returned- so i cant do the check on the 5th value as when only 1 value is returned it is considered by List Box as the first value not the 5th one.

I think perhaps in this case, i would need to add NULLS in first 4 rows and then the 5th value will come to its proper place.. Is that right but how would i do that?


Thanks


Quote:

Originally Posted by Rabbit

Only if it's a Value List, then you can use Me.ListboxName.RemoveItem()
If it's Table/Query, you'll need to change the Row Source. They both have the same aesthetic effect.

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#6: Jul 10 '07

re: list box values


I'm not following. Can you give me an example?

What is an example of the values in the listbox when it loads. Then what should it look like after you click something?
Site Addict
 
Join Date: Feb 2007
Posts: 553
#7: Jul 10 '07

re: list box values


For example, values are:

Value1
Value2
Value3

As i said , if Row 3 (Value3) is selected from ListBox then i call some functions to do some task

I have a button(its a part of requirement), when clicked, i am left with only Value3 in the ListBox . -- here comes the problem - Because Value3 is one only only value, it now comes on the first row of list box. So i cant do the above mentioned calling of funtions because now it is Value3 in Row 3 and previously it was Value1 in Row3 !! you know what i mean? I have conditions on row not on values

So i when i am in the case when there is only one value in List Box (in row 1), i would perhaps manually add 2 NULLS values so that Value3 comes back to its original place - Row 3 ---- If this is right, how can dio this



Quote:

Originally Posted by Rabbit

I'm not following. Can you give me an example?

What is an example of the values in the listbox when it loads. Then what should it look like after you click something?

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#8: Jul 10 '07

re: list box values


Quote:

Originally Posted by questionit

For example, values are:

Value1
Value2
Value3

As i said , if Row 3 (Value3) is selected from ListBox then i call some functions to do some task

I have a button(its a part of requirement), when clicked, i am left with only Value3 in the ListBox . -- here comes the problem - Because Value3 is one only only value, it now comes on the first row of list box. So i cant do the above mentioned calling of funtions because now it is Value3 in Row 3 and previously it was Value1 in Row3 !! you know what i mean? I have conditions on row not on values

So i when i am in the case when there is only one value in List Box (in row 1), i would perhaps manually add 2 NULLS values so that Value3 comes back to its original place - Row 3 ---- If this is right, how can dio this

Why are you doing the calculation based on row number rather than an ID of some sort?

Are you saying if the values were:
Value3
Value2
Value1

You would now do the calculation on Value1? I don't follow the rhyme and reason for this.
Site Addict
 
Join Date: Feb 2007
Posts: 553
#9: Jul 10 '07

re: list box values


I know but i am working on already developed big project, the guys have done it this way.

You have told me to use ME.ListBoxName.AddItem() for VBA . But i get error, saying this doesn't exist

for the list box which fethces value from table/query, can we not write a sql statement with UPDATE thing to update values in the ListBox ?



Quote:

Originally Posted by Rabbit

Why are you doing the calculation based on row number rather than an ID of some sort?

Are you saying if the values were:
Value3
Value2
Value1

You would now do the calculation on Value1? I don't follow the rhyme and reason for this.

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#10: Jul 10 '07

re: list box values


To use the SQL update, it would have to change the values in the table and then you would have to requery the row source.

.AddItem() only works if your listbox is a Value List.

Why not change the code so that the calculation isn't done on the third row but on the value you want no matter where it is in the listbox.
Reply