Dear Thomas:
From your sample code, it would appear "rs" is a RecordSet. This RecordSet
would be based on either a query or a table. Somewhere in the code you did
not show, this would be apparent.
The combo box properties do not include a "recordSet" property. A good way
to exploit the facilities for object oriented programming in Access is to
type in everything in lower case and see if it changes automatically.
For example, when you type in:
me.cbox.rowsourcetype = "Table/Query"
It changes to:
Me.cbox.RowSourceType = "Table/Query"
This confirms that you have successfully referenced object "Me" and property
"RowSourceType". It indirectly shows you have correctly referenced "cbox"
even though the name did not contain any capital letters. If you had
misspelled this, it would not then have found that the object "cbox" had a
property "RowSourceType" and that property would still have read
"rowsourcetype".
I strongly recommend this as a "best practice" when writing object oriented
code. Use mixed case in the object names you create. This makes them
easier to read in many cases, but especially it allows quick confirmation of
any early bound references. That will avoid many errors in programming, as
I'm about to illustrate.
Now, in the line of code:
Me.cbox.recordSet = rs
I expect the capital S came from you typing it that way. Had you entered
(as I just suggested):
me.cbox.recordset = rs
it would have come back:
Me.cbox.recordset = rs
Here was a big lost opportunity. When it does not come back, as you should
have expected:
Me.cbox.RecordSet = rs
it should be clear that the combo box "cbox" does not have a property
RecordSet (the actual name of a property which does exist for some objects).
I do not know for an absolute fact if it is the case that no objects or
properties in the library from Microsoft are without any capital letters,
but I do know that, if I type one in in lower case and nothing gets
capitalized, then I get very suspicious.
So, this is the primary resource you have to find out the error here. There
is no such property of a combo box.
So, given that you do have a table or query behind the recordset you used,
there must be a table name or SQL string which can be the RowSource of the
combo box. It is this string, used to set up the recordset, which can be
used to assign the RowSource of the combo box. Not only this, but the
assignment can be made in the form's design view, already attached to the
combo box. Both the RowSourceType and the RowSource can be set there, and
need not be coded at all unless they must change programatically. Indeed, I
have never needed to change the RowSourceType of a combo box, even when its
RowSource does change in code.
It would seem you are probably making something that is very simple into
something laborious to construct and which will be unnecessarily difficult
to maintain, given that it is usually possible to set the combo box contol's
properties once as you design, and never need to code them unless they need
to change dynamically.
Please let me know if this helped, and if I can be of any other assistance.
Tom Ellison