Greetings wise ones
FrmMain comprises 2 subforms.
Sub1 has scrolling list of all client names.
Sub2 has specific details of client's records.
Both are subforms of FrmMain, not one of the other.
The user can:
a) clicks on a name in sub1 which filters sub2 to show only details of that client's particular record; or
b) can apply filters to all records via sub2 to search for, for the sake of the example, all clients with the same postcode + last name begins with a 'q'.
Standard stuff.
All above works fine, Until it comes to generating a report based upon the filtered recordset. The following code is in the on_open event of my report:
Now,
- Report will generate fine using (a) above.
- Can generate a report of all records if they are not filtered; but
- try to filter records via sub2 and open report, the report asks for the parameter value for the control by sub2 was filtered.
Have tried 'Forms!FrmMain.Sub2.Form' vs 'Forms!FrmMain!Sub2.Form' with no success.
What makes this all the more infuriating is that this code works just fine when data is not included in a subform but on the mainform. ie Forms!FrmMain.Form
Any ponderances gratefully acknowledged.
Regards
xentaur
FrmMain comprises 2 subforms.
Sub1 has scrolling list of all client names.
Sub2 has specific details of client's records.
Both are subforms of FrmMain, not one of the other.
The user can:
a) clicks on a name in sub1 which filters sub2 to show only details of that client's particular record; or
b) can apply filters to all records via sub2 to search for, for the sake of the example, all clients with the same postcode + last name begins with a 'q'.
Standard stuff.
All above works fine, Until it comes to generating a report based upon the filtered recordset. The following code is in the on_open event of my report:
Code:
Private Sub Report_Open(Cancel As Integer)
Dim frm As Form
Set frm = Forms!FrmMain.Sub2.Form
Me.RecordSource = frm.RecordSource
If (frm.FilterOn) Then
Me.Filter = frm.Filter
Me.FilterOn = True
End If
Me.OrderBy = frm.OrderBy
Me.OrderByOn = True
End Sub
Now,
- Report will generate fine using (a) above.
- Can generate a report of all records if they are not filtered; but
- try to filter records via sub2 and open report, the report asks for the parameter value for the control by sub2 was filtered.
Have tried 'Forms!FrmMain.Sub2.Form' vs 'Forms!FrmMain!Sub2.Form' with no success.
What makes this all the more infuriating is that this code works just fine when data is not included in a subform but on the mainform. ie Forms!FrmMain.Form
Any ponderances gratefully acknowledged.
Regards
xentaur