5 pts.
 How to pass a Whereclause from a form to another form’s subform in Access 2000?
In FormA, I have a start_date and end_date fields for users to select the date range. The start_date and end_date will pass to FormB.subform where the subform is a continous form to display the records after filtered by the date range. My question is: how can I pass the date range to the subform of FormB? I have the following two lines in FormA codes. But it is not right because FormB doesn't have data source, only its subform has. strWhere = "LatestDate >= #" & Me!FromDate & "# And LatestDate <= #" & Me!ToDate & "#" DoCmd.OpenForm "FormB", acNormal, , strWhere My question is: how can I pass the parameters to subform?

Software/Hardware used:
ASKED: April 23, 2008  2:28 AM
UPDATED: April 25, 2008  8:22 PM

Answer Wiki:
You can use the openargs parameter of the OpenForm method to pass in the strWhere string. In FormB, use the OnOpen event to get the parameter passed in by referencing me.openargs. Then set the subforms filter property with the where string. ex. for FormB Sub Form_Open me!subform.form.filter = me.openargs me!subform.form.filteron = true End sub or Let say the subform in FormB has a record source of Table1 you could do this in FormB: Sub Form_Open me!subform.form.recordsource = "select * from Table1 " & me.openargs End Sub
Last Wiki Answer Submitted:  April 25, 2008  8:22 pm  by  Dwaltr   900 pts.
All Answer Wiki Contributors:  Dwaltr   900 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _