By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,659 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,659 IT Pros & Developers. It's quick & easy.

How to retrieve actual recordset from a subform

100+
P: 759
Hello !
I have a form: frmMain. In this form a subform: frmSubform.
When I navigate in frmMain the records in frmSubform are changed adequately.
Well done !

Now, I wish to create a string by concatenate the records (from a certain field) from this subform.
Can I do that by using directly what I have (what I see) in the frmSubform for a certain record in frmMain ?
That means to access only the filtered records from the subform.

Thank you !
Apr 13 '12 #1

✓ answered by limweizhong

I think you might have the RecordsetClone property if you are using Access 2007. You can try that in place of the Recordset property...

Or you can Set Rst=Form_frmStatments_subform.Recordset.Clone().

Edit: OK, RecordsetClone is also available in previous versions of Access.

Share this Question
Share on Google+
5 Replies


P: 62
Try using the child form's recordset, e.g. Child0.Form.RecordSet, but it might actually affect the record selector's position in the child form. Best way might be to do a separate query.

Edit: Yes it is really the displayed recordset in the form, so you might want to call Child0.Form.MoveFirst before and after your cycling through all the records.
Apr 13 '12 #2

100+
P: 759
I have trying that and work OK (I can print in Immediate Window what I need) but, indeed, the record selector is affected in the child form.
So I think that I need to use a clone for this recordset. But I don't know how to obtain this clone.

Here is the current code I use:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdPreviewSketch_Click()
  2. Dim Rst As DAO.Recordset
  3. Set Rst = Form_frmStatments_subform.Recordset
  4.     Rst.MoveFirst
  5.     Do While Not Rst.EOF()
  6.         With Rst
  7.             Debug.Print !Statment 'Statment is the field name
  8.             .MoveNext
  9.         End With
  10.     Loop
  11. Exit Sub
Apr 13 '12 #3

100+
P: 759
Solved somehow.
The subform must be requery after using it's recordset.
So, one more statement after line #10:
Expand|Select|Wrap|Line Numbers
  1. Form_frmStatments_subform.Requery
But I still think that using a clone is a better solution. Can this be achieved ?
Apr 13 '12 #4

P: 62
I think you might have the RecordsetClone property if you are using Access 2007. You can try that in place of the Recordset property...

Or you can Set Rst=Form_frmStatments_subform.Recordset.Clone().

Edit: OK, RecordsetClone is also available in previous versions of Access.
Apr 13 '12 #5

100+
P: 759
Yes !!!!!! That is. Thank you limweizhong !
As you I am looking for Subform.Recordset.Clone too but it is Subform.RecordsetClone. Uffff !
Expand|Select|Wrap|Line Numbers
  1. Dim Rst As DAO.Recordset
  2. Set Rst = Form_SubformName.RecordsetClone
  3.     Rst.MoveFirst
  4.     Do While Not Rst.EOF()
  5.         With Rst
  6.             'Do something
  7.             .MoveNext
  8.         End With
  9.     Loop
Apr 13 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.