ComboBox's Recordset?

B

bruce

Dear guys:

Since there is a RowSource property for ComboBox already, What does
ComboBox's Recordset property means? Can I use it to fill the list of
options in ComboBox?

Thanks for any of your instruction!
 
T

tina

from Access Help:

"The Recordset property returns the recordset object that provides the data
being browsed in a form, report, list box control, or combo box control. If
a form is based on a query, for example, referring to the Recordset property
is the equivalent of cloning a Recordset object by using the same query."

i've never used the Recordset property of a combobox control, but usually
you use the Recordset of a form when you want to examine or manipulate the
data returned by the form's RecordSource, but "outside of" the normal
form/user interaction - for instance, to do a search of all records without
moving from record to record in the form itself, as the Help topic
demonstrates. so i'd say you'd probably use a combobox's Recordset property
for the same sort of reason. if you want to change the control's RowSource,
i'd manipulate the RowSource property directly.

hth
 
G

Guest

Yes, you can use the Recordset property of a combo or list box to fill its
list with an open recordset, and I think this was probably what the MS Access
developers had in mind as its principal use. Its not something which is done
frequently as in most cases its easy to assign an SQL statement to the
control's RowSource property, but at times that might be difficult if you
want to use an open recordset to fill the list.

To try it create a form bound to a table or query and add an unbound combo
or list box to it. Then add a button to the form with this in its Click
event procedure:

Set YourCombo.Recordset = Me.RecordsetClone

Click the button and then drop down the combo box's list and you'll see rows
from the form's current recordset. Of course the columns you see will depend
on the combo box's ColumnCount and ColumnWidths properties.

Now filter the form using the Filter by Form or Filter by Selection facility
and click the button again. You should now see just the filtered rows in the
combo box's list.

For some reason the above seems to work more reliably by referencing the
form's RecordsetClone property rather than its Recordset property. The
latter will work, but I found it took two clicks of the button after turning
the filter on and off to update the list.

You can of course also assign an open ADO or DAO recordset to the control's
Recordset property.

Ken Sheridan
Stafford, England
 
L

Larry Linson

bruce said:
Thanks alot, I'll try what you say!

Good. Let us know the circumstances you have found under which using the
Recordset propery to set the Row Source would be useful / desirable. I only
ask because I have used Access daily since 1993 and have never had occasion
where I needed / wanted to do this.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top