[RESOLVED] list10.column(0).additem? hah!
VB Code:
Private Sub Command2_Click()
Rem fetch
Me.List10.RowSource = ""
rst.Open "select * from Qns_Table", cn
rst.MoveFirst
Do While Not rst.EOF
Me.List10.AddItem rst!QnsID
'Me.List10.AddItem rst!Question
rst.MoveNext
Loop
rst.Close
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
Re: list10.column(0).additem? hah!
to add items to the columns in a list box do
VB Code:
Me.List10.AddItem rst!QnsID &";" & rst!Question
Re: list10.column(0).additem? hah!
Quote:
Originally Posted by dannymking
to add items to the columns in a list box do
VB Code:
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
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?
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
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!)
Re: list10.column(0).additem? hah!
Hey Ecniv,
I got it man.
Me.List10.AddItem rst!QnsID & ";" & rst!Question & ";"
Thanks anyway! =)
Astro
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..
Re: [RESOLVED] list10.column(0).additem? hah!
Hey dannymking,
I got it!
Thanks!
Astro