为什么我无法在 form_open 中将过滤器设置为 属性?
Why I Cant set the FilterOn property in form_open?
我尝试在access中设置一个连续形式的过滤器vba。这是我使用的代码:
Private Sub Form_Open(Cancel As Integer)
Dim filter As String
filter = "1 = 0" ' "1=0" is just for testing purpurses
Me.filter = filter
Me.FilterOn = True
Debug.Print Me.FilterOn & "; " & Me.filter
end sub
输出为:
False; 1 = 0
并且没有使用过滤器。
为什么这不起作用?有没有办法在显示表单之前设置和激活过滤器?
我发现原因是。我使用一个框架,稍后我会在其中设置记录源。虽然没有记录源,但“Me.FilterOn = True”根本不起作用。以下代码确实有效:
Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "select * from MyTable"
Dim filter As String
filter = "1 = 0" ' "1=0" is just for testing purpurses
Me.filter = filter
Me.FilterOn = True
Debug.Print Me.FilterOn & "; " & Me.filter
end sub
输出为:
True; 1 = 0
我尝试在access中设置一个连续形式的过滤器vba。这是我使用的代码:
Private Sub Form_Open(Cancel As Integer)
Dim filter As String
filter = "1 = 0" ' "1=0" is just for testing purpurses
Me.filter = filter
Me.FilterOn = True
Debug.Print Me.FilterOn & "; " & Me.filter
end sub
输出为:
False; 1 = 0
并且没有使用过滤器。
为什么这不起作用?有没有办法在显示表单之前设置和激活过滤器?
我发现原因是。我使用一个框架,稍后我会在其中设置记录源。虽然没有记录源,但“Me.FilterOn = True”根本不起作用。以下代码确实有效:
Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = "select * from MyTable"
Dim filter As String
filter = "1 = 0" ' "1=0" is just for testing purpurses
Me.filter = filter
Me.FilterOn = True
Debug.Print Me.FilterOn & "; " & Me.filter
end sub
输出为:
True; 1 = 0