How to pass a Whereclause from a form to another form’s subform in Access 2000?

5 pts.
Tags:
Microsoft Access
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?

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Wonder19
    [...] Whereclause from a form to another form??s subform in Access 2000? New Question Created by Wonder19http://itknowledgeexchange.techtarget.com/itanswers/how-to-pass-a-whereclause-from-a-form-to-another...View Member - Wonder19Wonder19 Login Name. Premium Service Member Account Type. 0 Expert Points. [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following