|
-
Sep 15th, 2005, 08:12 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] MS Access VBA addItem List view
I am getting an error on this line of code, hope someone can help.
As you can see all I want to do is loop through the dataset and add column 1 to a list view for each row.
VB Code:
Me.lstEmpStates.RowSourceType = ValueList
While Not rs.BOF And Not rs.EOF
[U]Me.lstEmpStates.Additem rs.DataMember(rs.RecordCount, 1)[/U]
rs.MoveNext
-
Sep 15th, 2005, 08:48 AM
#2
Thread Starter
Frenzied Member
Re: MS Access VBA addItem List view
Me.lstEmpStates.Additem
This is the offending piece of code I think. Error Method or data member not found. I have set the source type to value list so cant see the problem?
Anyone?
-
Sep 15th, 2005, 09:25 AM
#3
Frenzied Member
Re: MS Access VBA addItem List view
I think to use the .AddItem on a listbox it has to be a CommandBar listbox, which I've never used. The listbox control in the toolbox doesn't have an .Additem method that I know of. You can set the contents to a data source, like a table or query, or enter a value list.
Tengo mas preguntas que contestas
-
Sep 15th, 2005, 09:43 AM
#4
Thread Starter
Frenzied Member
Re: MS Access VBA addItem List view
OK yes add item is on 2003 and im on 2000.
I have a workaround by using a value list
i.e Build a comma delimited string then
Me.lstEmpStates.RowSource = strStates
My trouble now is building the string
While Not rs.BOF And Not rs.EOF
strStates = strStates & ";" & rs.DataMember(0, 1)
rs.MoveNext
Wend
As you can see I am just wanting to get column 1 into the string as I loop through the record set but the syntax is wrong.
hlp pls
-
Sep 15th, 2005, 09:55 AM
#5
Re: MS Access VBA addItem List view
what is rs?
what is datamember?
if rs is a recordset then use rs("<fieldname>") - will work except (possibly) for null values.
Also there is a character limit on the list box for values, but if you are not going near that limit you should be ok.
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...
-
Sep 15th, 2005, 10:03 AM
#6
Thread Starter
Frenzied Member
Re: MS Access VBA addItem List view
Thanks Ecniv
http://msdn.microsoft.com/library/de...html/ino2k.asp
Also keep in mind that there's a limit on just how long a control's RowSource property can be, and that limit is 2,048 characters
I think that should be enough
-
Sep 15th, 2005, 10:07 AM
#7
Frenzied Member
Re: [RESOLVED] MS Access VBA addItem List view
Another option is to write the values you want to a temp table and use that as a rowsource. That way you could sort, select, etc.
Tengo mas preguntas que contestas
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
|