Results 1 to 9 of 9

Thread: [RESOLVED] list10.column(0).additem? hah!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Resolved [RESOLVED] list10.column(0).additem? hah!

    VB Code:
    1. Private Sub Command2_Click()
    2. Rem fetch
    3. Me.List10.RowSource = ""
    4. rst.Open "select * from Qns_Table", cn
    5. rst.MoveFirst
    6. Do While Not rst.EOF
    7.     Me.List10.AddItem rst!QnsID
    8.     'Me.List10.AddItem rst!Question
    9.     rst.MoveNext
    10. Loop
    11. rst.Close
    12. End Sub

    is there anyway that i can have my QnsID and Question displayed in seperate column of the List10 (list box)?

    i've tried something out of the world and here goes...
    Me.List10.Column(0).AddItem rst!QnsID
    Me.List10.Column(1).AddItem rst!Question

    of course, it isn't suppose to work =P

    can someone advice me on this?

    Thanks

    Astro

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: list10.column(0).additem? hah!

    to add items to the columns in a list box do

    VB Code:
    1. Me.List10.AddItem rst!QnsID &";" & rst!Question
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: list10.column(0).additem? hah!

    Quote Originally Posted by dannymking
    to add items to the columns in a list box do

    VB Code:
    1. Me.List10.AddItem rst!QnsID &";" & rst!Question

    Hey dannymking,

    thanks for replying. i understand that, that will add items from the table into the listbox's only column.

    what if i have two columns? how do i put QnsID and Question into column 1 and 2 of the listbox respectively.

    Thank you.

    Astro

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: list10.column(0).additem? hah!

    On design of the form.
    Select the listbox.
    Open the properties window.
    Look for columns, and change to 2 (or more).
    I think there is a column widths property too, so if you need to hide one just set that column to 0.

    In access I think the column widths were separated by semi-colons ( ; )'s might be the same in VB?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: list10.column(0).additem? hah!

    Quote Originally Posted by Ecniv
    On design of the form.
    Select the listbox.
    Open the properties window.
    Look for columns, and change to 2 (or more).
    I think there is a column widths property too, so if you need to hide one just set that column to 0.

    In access I think the column widths were separated by semi-colons ( ; )'s might be the same in VB?

    yup Ecniv, i've already one that. just need to additem into it's respective column.

    Thanks

  6. #6
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: list10.column(0).additem? hah!

    Code:
    listbox.additem ""
    lngLast = listbox.listcount -1
    listbox.list(lngLast,0)="ID"
    listbox.list(lngLast,1)="Disp data"
    Something like that?
    I am not sure it is list, but you should have the intellisense, have a look through that. Might be listitem. Or Item (sorry cannot remember!)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: list10.column(0).additem? hah!

    Hey Ecniv,

    I got it man.

    Me.List10.AddItem rst!QnsID & ";" & rst!Question & ";"

    Thanks anyway! =)

    Astro

  8. #8
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: list10.column(0).additem? hah!

    As I originally stated..

    Been off work for a week and a half, and not had much chance to visit recently due to training course in manchester.

    When you specify .AddItem and include a semicolon between two items you are infact adding to both columns, or three if you include two semicolons and so on..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Re: [RESOLVED] list10.column(0).additem? hah!

    Hey dannymking,

    I got it!

    Thanks!

    Astro

Posting Permissions

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



Click Here to Expand Forum to Full Width