469,342 Members | 5,392 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

How to retrieve actual recordset from a subform

759 512MB
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.

5 15504
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
Mihail
759 512MB
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
Mihail
759 512MB
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
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
Mihail
759 512MB
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.

Similar topics

4 posts views Thread by Thomas Scheiderich | last post: by
1 post views Thread by Robin Hammond | last post: by
3 posts views Thread by tony wong | last post: by
1 post views Thread by mark_aok | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.