Click to See Complete Forum and Search --> : Access VBA listbox question
SmagO
Jul 28th, 2003, 05:07 AM
Hi,
Please help with adding items to a listbox using a form in Access. I dont want to use the access wizard feature of having the listbox automatically populated. Rather I want to enter a value and have that value populate into the listbox.
I thought i could just go:
list1.additem ("red")
but it doesnt recognise the additem referance.
Thanks!
:confused: :confused:
remvs
Jul 28th, 2003, 07:44 AM
Hi,
.AddItem should do the job. Dunno whats wrong there
- did you watch the declarations (private, public etc)?
- did u save the file?
remvs
Granty
Jul 29th, 2003, 08:53 AM
.AddItem does not exist in Access 97 List/Combo boxes.
Get your recordset then:
Do While Not rs.EOF
strData = strData & rs!dtmDateTime & ";"
rs.MoveNext
Loop
If Not IsNothing(strData) Then
strData = Left(strData, Len(strData) - 1)
End If
ComboName.RowSource = strData
Edit: Isnothing is just a function I wrote to check for Nulls and Empties.
Matt_T_hat
Aug 5th, 2003, 07:56 AM
Originally posted by SmagO
Hi,
Please help with adding items to a listbox using a form in Access. I dont want to use the access wizard feature of having the listbox automatically populated. Rather I want to enter a value and have that value populate into the listbox.
I would have considered useing a seperate table List_of_Choices and use it to populate Combos and listboxes. Thatway I could edit it at runtime.
M Owen
Aug 6th, 2003, 07:21 AM
The AddItem method is not available until Access 2002 ... Access 2000 doesn't have it either ... Depending on the # of items you need to put the list you can create a temporary table and populate it and bind that to the listbox or you can make the listbox a "Value List" and concat the items together into a string separated by semicolons and assign that string to the RowSource property ...
Eras3r
Aug 15th, 2003, 03:27 PM
ya, vba listboxes are not nice in that respect.
myListData = myListData & ";" & NewItem
myList.RowSource = myListData
..... It's slow too.
But there is good news!! You can use VB6 listboxes in VBA. Just use "Microsoft Forms 2.0 Listbox" from the "More Controls" list. Then you will notice you've got your .AddItem.. and all those other nifty VB6 options :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.