navigating a subform in code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have subforms that the user will compare and the code will operate on. (I
did not compose the subform recordsources in code, but used the form wizard,
instead.) I have discovered that the record number of the selected record in
a subform is

frmName.frmSubName.CurrentRecord

but what is the syntax for retrieving the number of rows in the recordsource
associated with the subform?

Thanks!
 
Allen_N said:
I have subforms that the user will compare and the code will operate on. (I
did not compose the subform recordsources in code, but used the form wizard,
instead.) I have discovered that the record number of the selected record in
a subform is

frmName.frmSubName.CurrentRecord

but what is the syntax for retrieving the number of rows in the recordsource
associated with the subform?


In the main form, the VBA syntax should be:
Me.frmSubName.Form.CurrentRecord

and the number of records would be:
Me.frmSubName.Form.RecordsetClone.RecordCount
but only if you have referenced/viewed the last record. To
make sure that has happened, you should add some code to the
subform's Load event:

With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveLast
End If
End With
 
My problems are just beginning. I want to create a report when the user is
happy with what's on the form and subforms. But, how do I refer to contents
of the subforms? (These were composed with linked child & master fields to
the main form, which is based on a stored query, and I don't know how to
apply the same data (recordsource? filter?) to the related report.)
 
The subreport's record source query is where you specify the
criteria for subreports that mimic the subforms.

OTOH, maybe you don't need subreports. By using a query
that Joins the related tables as the report's record source,
you might(?) be able to use the report's Sorting and
Grouping to organize the data. One benefit of this is that
you can create a dynamic filter and use it in the OpenReport
method's WhereCondition argument.
 

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

Back
Top