 |
|
 |
|
Next: Access 2002-sp3, Cannot open emaled file.
|
| Author |
Message |
External

Since: Feb 21, 2005 Posts: 1
|
(Msg. 1) Posted: Mon Feb 21, 2005 11:59 pm
Post subject: Recordset-adding to a Listview Archived from groups: microsoft>public>vb>database>ado (more info?)
|
|
|
I've got a weird problem - - - it must be something simple, but for the
life of me, I must be missing it...
I've got a recordset - and I'm trying to add the results into a listview,
but, instead of adding each successive record after the first line of the
listview, it adds it before (above) the line it just entered...
here's my code (recordset returned):
While Not rs.EOF
Set list_item = LView.ListItems.Add(rs("Filename"))
Debug.Print "filename=" & rs("Filename")
list_item.SubItems(1) = rs("Artist")
Debug.Print "Artist=" & rs("Artist")
.........etc
Recs = Recs + 1
rs.Next
Wend
I tested it by doing an order by Filename-DESC
the weirdest part is that, in the debug statements, if I step through it,
the records seem to be coming in correctly - Descending - but, since the
records are getting added into the listview above each entered item - it
ends up being Ascending --- and changing it to Ascending doesn't help
any ideas? - - - I have little or no hair left -- I've pulled it all out. >> Stay informed about: Recordset-adding to a Listview |
|
| Back to top |
|
 |  |
External

Since: Aug 13, 2004 Posts: 2
|
(Msg. 2) Posted: Tue Feb 22, 2005 7:47 am
Post subject: RE: Recordset-adding to a Listview [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Okay Elmo,
Let's see if we can preserve the rest of your hair.
The one thing that jumps out at me is the lack of including an index value
when inserting the record into the listview control. I know the BOL says
this value is optional, but IMO, that value should be required.
Try this ...
Dim nIndex as Integer
nIndex = 1
:
:
Do While ...
Set list_item = LView.ListItems.Add(nIndex, , rs.Fields("Filename").Value)
:
nIndex = nIndex + 1
Loop
That should populate the listview control the way you are expecting. Now
then, there are a couple of other issues ... highly opinionated and only a
visual bug.
1. The use of WHILE ... WEND is a deprecated structure back to the early
days of VB; use the DO WHILE ... LOOP instead.
2. When accessing your recordset values, use rs.Fields("Filename").Value
(fully qualified), and not the shorthand notation.
Again, these last two are just me being picky, and leaving them as-is will
not affect the outcome of your code. Give the listview idea a try. Good
luck; hope it works.
Richard
"Elmo Watson" wrote:
> I've got a weird problem - - - it must be something simple, but for the
> life of me, I must be missing it...
>
> I've got a recordset - and I'm trying to add the results into a listview,
> but, instead of adding each successive record after the first line of the
> listview, it adds it before (above) the line it just entered...
>
> here's my code (recordset returned):
>
> While Not rs.EOF
> Set list_item = LView.ListItems.Add(rs("Filename"))
> Debug.Print "filename=" & rs("Filename")
> list_item.SubItems(1) = rs("Artist")
> Debug.Print "Artist=" & rs("Artist")
> .........etc
> Recs = Recs + 1
> rs.Next
> Wend
> I tested it by doing an order by Filename-DESC
> the weirdest part is that, in the debug statements, if I step through it,
> the records seem to be coming in correctly - Descending - but, since the
> records are getting added into the listview above each entered item - it
> ends up being Ascending --- and changing it to Ascending doesn't help
>
> any ideas? - - - I have little or no hair left -- I've pulled it all out.
>
>
> >> Stay informed about: Recordset-adding to a Listview |
|
| Back to top |
|
 |  |
| Related Topics: | updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..
ADO recordset question - Hello all. This is such a basic question, but I can't find an answer. I have a function in a class module that finds data from a series of database tables. The data, when found, is placed into a new recordset within the function. All OK here. Now, wher...
ADODB.RecordSet - Hi, I have a client recordset returned via VB6. I'd like to know if it can be inserted to a phisical table on MS SQL SERVER containing the same fields...? It'd be like a "INSERT SELECT", but the source (select) would come from this adodb.rec...
VB6 using ADO, sproc with return recordset - VB6 code snippet: with cmd .cmdtext = "exec buildwordlist 11" .commandtype = adcmdtext end with set rs = cmd.execute() if not rs.eof then strfield = rs!fieldname rs.movenext end if the above code works just fine if the sproc is ...
Updating An ADO 2.6 Recordset With VB and Access - When I try to update my ADO Recordset like this: recSet.Fields(2).Value = strFileNum I get this: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. Error 3251 When I try t... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|