Access - 导航表单将记录源更改为目标名称并取消绑定控件

Access - Navigation Form Changes Record Source to Target Name and Unbinds Controls

我使用 VBA 筛选了一系列表单,在将表单添加到导航表单之前一切正常,然后返回错误消息“操作或方法无效,因为表单或报告不正确” '绑定到 table 或查询'

我认为...这是因为导航表单没有记录源...相反它有一个目标名称

在原始表格中 属性 记录源是 tblAvailableHours2

在导航窗体上,属性 是目标名称 Frm_Available_Capacity_Hours

这是一个简单的日期过滤器,

Private Sub ApplyDtFilt_Click()

    On Error GoTo ApplyDtFilt_Click_Err
    
     DoCmd.ApplyFilter , "[Start Date] Between #" & Format([AVstrtdt], "yyyy\/mm\/dd") & "# And #" & Format([AVEnDt], "yyyy\/mm\/dd") & "#"
     
    ApplyDtFilt_Click_Exit:
        Exit Sub
    ApplyDtFilt_Click_Err:
        MsgBox Error$
        Resume ApplyDtFilt_Click_Exit
    
End Sub

有没有办法将上述过滤器链接回 VBA 中的原始 table tblAvailableHours2 或操纵 属性 中的导航表单记录 source/target 名称 sheet 让它再次工作?

我没有使用导航表单,但如果您的表单是子表单,则必须通过包含它的子表单控件解决此问题:

Private Sub ApplyDtFilt_Click()

    On Error GoTo ApplyDtFilt_Click_Err

    With Me!NameOfSubformControlHoldingFrm_Available_Capacity_Hours.Form
        .Filter = "[Start Date] Between #" & Format([AVstrtdt], "yyyy\/mm\/dd") & "# And #" & Format([AVEnDt], "yyyy\/mm\/dd") & "#"
        .FilterOn = True
    End With
     
    ApplyDtFilt_Click_Exit:
        Exit Sub
    ApplyDtFilt_Click_Err:
        MsgBox Error$
        Resume ApplyDtFilt_Click_Exit
    
End Sub
Private Sub ApplyDtFilt_Click()
On Error GoTo ApplyDtFilt_Click_Err
     
     With Forms![EPM-V2]![NavigationSubform].Form
     Filter = "[Start Date] Between #" & Format([AVstrtdt], "yyyy\/mm\/dd") & "# And #" & Format([AVEnDt], "yyyy\/mm\/dd") & "#"
    .FilterOn = True
    End With

ApplyDtFilt_Click_Exit:
    Exit Sub
ApplyDtFilt_Click_Err:
    MsgBox Error$
    Resume ApplyDtFilt_Click_Exit
End Sub