list box values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    list box values

    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
    Recognized Expert MVP
    • Jan 2007
    • 12517

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

    Comment

    • questionit
      Contributor
      • Feb 2007
      • 553

      #3
      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 ??


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

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        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.

        Comment

        • questionit
          Contributor
          • Feb 2007
          • 553

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

          Me.lst_Heating_ Choice.RowSourc eType = "Table/Query"
          Me.lst_Heating_ Choice.RowSourc e = "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


          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.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            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?

            Comment

            • questionit
              Contributor
              • Feb 2007
              • 553

              #7
              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



              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?

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                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.

                Comment

                • questionit
                  Contributor
                  • Feb 2007
                  • 553

                  #9
                  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 ?



                  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.

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    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.

                    Comment

                    Working...