Subforms on an unbound ADO based form

  • Thread starter Thread starter Adam Steiner
  • Start date Start date
A

Adam Steiner

Hi,

Got another question (and thanks for answering the previous ones last
month).

I have an unbound form calling up data (concerning people) through an
ADO recordset. I have a subform which contains all of the donations
made by those people.

Since both the subform and regular form are unbound, I seem to have
trouble. I can't figure out which subform object I use to change the
recordset of the subform (to donorID=x) every time a new person is
loaded on the main form.

I've tried Me.Form.sbfrmName.Recordset = adoRsDonor as well as a couple
of others (I think one may have been recordsource). I sometimes get a
an error with the _Subform object of the form.

Any recommendations?

Thanks,

Adam
 
It helps to understand the model you're working with.
Me is the form in whose module you're working.
A control on it is Me.MyControl (or Me!MyControl).
If MyControl is a subform control, it contains a subform, so it has a .Form
property, which is
Me.MyControl.Form.
That form has both a RecordSource and a RecordSet property.
RecordSource (Me.MyControl.Form.RecordSource) is a string which gives the
name or SQL of the table/query to be used to define the records.
Recordset is a recordset object; as such, if you want to change it, you'll
need the Set keyword.

HTH
 
MacDermott,

Ok, that makes sense, but now I'm receiving the following error:
"Method 'Form' of object '_Subform' failed.

Here's the code (rsDonor is a form-wide recordset)

Private Sub Form_Load()
..
rsDonor.Source = strSQL
..
..
rsDonor.Open
Me.sbfrmCamDon.Form.Recordsource = "select..."

End Sub

When I tried having a Set Me.sbfrmCamDon.Form.Recordset =
rsDonorCampaign (where all recordsets mentioned are ADO) I received an
error stating that it is not a valid recordset object.

I can't help but get the feeling that this is one of those "I'll kick
myself" mistakes once I realize it. Thoughts?

Thanks again,
Adam
 
Sorry, thought I had mentioned it earlier.

I'm using Access 2k3.

--adam
 
Sometimes there is confusion between the subform control (which sits on the
main form, and is a control like a textbox or combobox) and the form which
is displayed in that control, and whose name is given as the SourceObject
property of the subform control.
Sometimes these two object have the same name; sometimes they don't.
Which is sbfrmCamDon? Is it one or both?
 
It is both. I guess I'll give it a shot and change one of them.

--Adam
 
Can you identify the line of code which is causing this error?
 
It worked, thanks MacDermott. I'm still having a problem with the
subform, but I'll hopefully be able to figure it out.
 

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

Similar Threads


Back
Top