Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Additem - 2nd Column 1

Status
Not open for further replies.

ZOR

Technical User
Joined
Jan 30, 2002
Messages
2,963
Location
GB
Can someone tell me the syntax to enable a second column item to be added to a listbox, and how to retrieve the second column - if it's possible. Thanks

Me.PickList2.AddItem WORDPICK

 
Just looked at the listbox, and it's a value list, so that might knock and second column on the head?
 
First to return something in the 2 or higher row:
1) the columns are numbered 0,1,2,.. So the second column is actually column number 1. A list box has a "column" property to return the value from a specified column, row.
2) the listindex is the row number and it is returned when you select a value. So to return the second column
listName.column(columnnumber,rownumber)
ex:
lstMyList.column(1,lstMyList.listindex)

to add an item your list box must have the column count property set to 2. If this is my value list:

"animal";"dog";"fruit";"apple" then I will have this

animal dog
fruit apple

if I want to add a third row then:
lstMyList.additem("car;ford") will add
car ford

Another alternative in older versions of Access:

lstMyList.rowsource = listMyList.rowsource & ";car;ford
 
Many thanks, well explained, and worked. Best regards
 
Can someone tell me why this code does not work.

AG = Me.L88.Column(3)
Me.PickList2.AddItem ("WORDPICK;AG")

AG goes into the list as AG. The previous attempt was using L88 but that just ended as wording??

Thanks
 
if you put a variable in quotes it assumes it is a string:

dim x as integer
x = 123
debug.print x
'prints 123
debug.print "x"
'prints x

you will have to build the string first

dim strInput as string
AG = Me.L88.Column(3)
strInput = "WORDPICK;" & AG
Me.PickList2.AddItem (strInput)
 
Many thanks. Managed to use :

Me.PickList2.AddItem "WORDPICK;" & AG

I had tried to split it up earlier, but got confused as Wordpick was/is a variable but that entered what was in it in the list. However AG is also a variable but it didn't show it's value?

Thanks again, regards
 
One, more. How do I force a column seperator in this.

strInput = WORDPICK ' String
strInput2 = AG ' Integer
Me.PickList2.AddItem (strInput) & (strInput2)

Probably an easier way to write syntax. Thanks
 
Trial and error found it-

Me.PickList2.AddItem strInput & ";" & strInput2

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top