Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2002
    Posts
    55

    Unhappy Unanswered: Listbox Display Problem

    I am trying to call a value from a table that relates to a listbox. What I want to have happen is that when the form opens, the listbox will take the values and highlight the rows in the listbox that relate to the values.

    The code below works if there is only one value:
    For intstatus = 0 To cbo_Status.ListCount - 1
    cbo_Status.Selected(Status_Hidden) = True
    Next intstatus


    I am trying to figure out how to accomplish the same task when multiple selections exist and are stored (e.g., "1,2,3").

    The problem is I can't pass multiple values at once into the .Selected statement.

    Help!

    TIA

  2. #2
    Join Date
    Sep 2004
    Posts
    161
    I think you must have the intstatus in the selected like this
    cbo_Status.Selected(intstatus) = True
    The intstatus give the row of the list box
    if Status_hiden is the value you want for the row selected, test this solution
    cbo_Status.Selected(intstatus) = cbo_Status.Column(Num_of_column Status_hiden,intstatus)

  3. #3
    Join Date
    Feb 2002
    Posts
    55
    I am having some trouble getting that to work for me (it's probably me though).

    Basically, I have a listbox field called cbo_Status. The values for the field are: New,Pending,On Hold, Completed

    The field can actually be made up of multiple responses (e.g., It can be both "New" and "On Hold").

    When a user selects the values in the listbox, a corresponding numeric value is stored in a table (e.g., If "New" = 1 and "On Hold" =3 then the table value stored would be 1,3).

    What I want is that when I re-open the database at a later date, "New" and "On Hold" would be the only two rows highlighted.

    The number of possible selections is variable and can be any amount up to the number of possible choices for the listbox. Where I hit the snag is when there is multiple values (such as in the 1,3 example), it fails because I am not certain how to parse this out.

    Thanks again...

  4. #4
    Join Date
    Sep 2004
    Posts
    161
    If I understand
    You have a form with base on a table, an when you display a record from this table you want highlighted the differents states of your record in the listbox. How is stored this value ?

  5. #5
    Join Date
    Feb 2002
    Posts
    55
    The values are stored with comma delimitation 1,2,3...

    but I can convert this to another format if necessary.

  6. #6
    Join Date
    Sep 2004
    Posts
    161
    All wright....
    You can try this :
    Define your listbox like :
    ColumnCount : 2
    ColumnWiths: Lenght_fo_state;0 (the second column do not appears)
    ListRows : Number of state possible
    RowSource : In french "liste de valeurs" , in english ValueList ?
    RowSourceType : New;1;Pending;2;On Hold;3; Completed;4

    and put this code (I assume the name of the Field is State)
    For intstatus = 0 To cbo_Status.ListCount - 1
    if instr(1,Table![State],cbo_status.Column(1,intstatus))>0 then
    cbo_Status.Selected(ntstatus ) = True
    end if
    Next intstatus

  7. #7
    Join Date
    Feb 2002
    Posts
    55
    Thank you, but it is still not working to my expectation. I have dummied up a sample DB that I think will clarify the issue.

    My end goal is that when the database is closed and later reopened, it will have the fields that were set highlighted.

    Thanks...
    Attached Files Attached Files

  8. #8
    Join Date
    Sep 2004
    Posts
    161
    I can't open your base, i'm working with 97
    Ouuups I'm sorry i give you a solution with a combo box not a list box. he only dif. is the columncount do not exist on listbox. Otherwise that's good.
    I join my test base
    Attached Files Attached Files

  9. #9
    Join Date
    Aug 2004
    Location
    Steamboat Springs, CO
    Posts
    37
    Jepi is right, the key to having the list box show the currently selected values is to set the row source type as value list.

    J

  10. #10
    Join Date
    Feb 2002
    Posts
    55
    That did the trick... THANKS!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •