Reputation: 390
IN MSAccess, I have a report which summarizes the records. I want to be able to click the 'Formdate" field on the report and open the corresponding record in a "MAF View" form.
The following code opens the "MAF View" form, but applies the filter to the report instead of the form. How do I apply the filter to the form instead?
Dim strFilter As Variant
strFilter = "[Formdate] = #" & Format(Me!FormDate.Value, "mm\/dd\/yyyy") & "#"
Me.Filter = strFilter
FilterOn = True
DoCmd.OpenForm "Maf View", , strFilter
Upvotes: 0
Views: 93
Reputation: 27644
DoCmd.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
You have strFilter
in the FilterName
argument instead of WhereCondition
. A query name would go there, but not a SQL WHERE condition.
Either do
DoCmd.OpenForm "Maf View", , , strFilter
or - much better readable! - use named parameters:
DoCmd.OpenForm "Maf View", WhereCondition:=strFilter
Upvotes: 1