是否可以过滤引用子表单的控件?
Is it possible to filter a control that refers to a subform?
这是我指的代码:
Dim ctl as Control
For Each ctl In Me.Form
If ctl.ControlType = acSubform
ctl.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
ctl.FilterOn = True
End If
Next ctl
显然这是行不通的(这与过滤器字符串无效无关)。我猜我不能在控制对象上使用 Filter 方法。但是有办法解决这个问题吗?也许创建一个 SubForm 变量并以某种方式将其分配给 Control 所指的对象?帮助!谢谢!
没有多大意义。您既不能也不会在所有控件上应用过滤器。
这就是你可能想到的:
With Me!NameOfYourSubformControl.Form
.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
.FilterOn = True
End With
那么就是:
Dim ctl as Control
For Each ctl In Me.Form
If ctl.ControlType = acSubform
ctl.Form.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
ctl.Form.FilterOn = True
End If
Next ctl
这是我指的代码:
Dim ctl as Control
For Each ctl In Me.Form
If ctl.ControlType = acSubform
ctl.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
ctl.FilterOn = True
End If
Next ctl
显然这是行不通的(这与过滤器字符串无效无关)。我猜我不能在控制对象上使用 Filter 方法。但是有办法解决这个问题吗?也许创建一个 SubForm 变量并以某种方式将其分配给 Control 所指的对象?帮助!谢谢!
没有多大意义。您既不能也不会在所有控件上应用过滤器。
这就是你可能想到的:
With Me!NameOfYourSubformControl.Form
.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
.FilterOn = True
End With
那么就是:
Dim ctl as Control
For Each ctl In Me.Form
If ctl.ControlType = acSubform
ctl.Form.Filter = "[StartDate] <= [Date] and [EndDate] >= [Date]"
ctl.Form.FilterOn = True
End If
Next ctl