|
|
|
date: Mon, 15 May 2006 15:54:34 +0200,
group: microsoft.public.word.vba.userforms
back
Re: Picking records/rows from a recordset
Hi Ebbe,
> How do I bind the rows in the recordset and the rows in the listbox?
> I know how to walk through a recordset and insert rows in a listbox.
> But how do I go back to the correct row in the recordset, when I have a
> selected row in the listbox?
>
Well, there's no way to "bind" the recordset. you have to put something in
the list that will let you go back to the recordset and look up the
user's choice. If you can't rely on the Index of the selected item
(first, second, third entry in the list), then you have to pick up a value
from a column in the list and requery the data source based on that.
usually, that would be the primary key...
You should be able to hide any column by setting its width to 0, and you
can also set the Bound column to this column. Read up in the VBA Help on
the BoundColumn property to see how to use it.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
date: Tue, 16 May 2006 17:29:15 +0200
author: Cindy M -WordMVP-
Re: Picking records/rows from a recordset
Hi Cindy
I have an acceptable result setting the index to the list, when I execute
rs.MoveFirst and count the index up by One when I execute rs.MoveNext.
In this way I am walking through the list and the recordset synchronously.
I close the case here with thanks for answers I have got.
Ebbe
"Cindy M -WordMVP-" skrev i en meddelelse
news:VA.0000bf8f.00ad68d2@speedy...
> Hi Ebbe,
>
>> How do I bind the rows in the recordset and the rows in the listbox?
>> I know how to walk through a recordset and insert rows in a listbox.
>> But how do I go back to the correct row in the recordset, when I have a
>> selected row in the listbox?
>>
> Well, there's no way to "bind" the recordset. you have to put something in
> the list that will let you go back to the recordset and look up the
> user's choice. If you can't rely on the Index of the selected item
> (first, second, third entry in the list), then you have to pick up a value
> from a column in the list and requery the data source based on that.
> usually, that would be the primary key...
>
> You should be able to hide any column by setting its width to 0, and you
> can also set the Bound column to this column. Read up in the VBA Help on
> the BoundColumn property to see how to use it.
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
> http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
>
date: Tue, 16 May 2006 22:25:23 +0200
author: Ebbe
|
|