|
-
Jul 28th, 2003, 05:07 AM
#1
Thread Starter
Lively Member
Access VBA listbox question
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:
Code:
list1.additem ("red")
but it doesnt recognise the additem referance.
Thanks!
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
-
Jul 28th, 2003, 07:44 AM
#2
Lively Member
Hi,
.AddItem should do the job. Dunno whats wrong there
- did you watch the declarations (private, public etc)?
- did u save the file?
remvs
-
Jul 29th, 2003, 08:53 AM
#3
Hyperactive Member
.AddItem does not exist in Access 97 List/Combo boxes.
Get your recordset then:
Code:
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.
-
Aug 5th, 2003, 07:56 AM
#4
Fanatic Member
Re: Access VBA listbox question
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.
-
Aug 6th, 2003, 07:21 AM
#5
Lively Member
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 ...
-
Aug 15th, 2003, 03:27 PM
#6
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|