如何将子表单链接到主表单上的组合框

发布于 2024-09-24 04:54:23 字数 355 浏览 4 评论 0原文

在访问 ADP 的表单上,有一个未绑定的组合框,用于显示公司列表(显示名称,id 是绑定字段)。选择一家公司后,我想在子表单(其数据源是companySubscription 视图)中显示该公司的订阅信息。我设置了链接主字段并将子表单的子字段属性链接到 companyId。基本上,我设置它像这样

从理论上讲,我认为这意味着当我更改组合框中的值时,子表单应该显示该公司的订阅信息。但它不起作用 - 子表单始终显示 companySubscription 视图中的所有数据,无论组合框设置为什么。

On a form in an access ADP there is an unbound combobox that displays a list of companies (the name is shown, the id is the bound field). When a company is chosen, I want to display the subscription information in a subform (the datasource for which is companySubscription view) for that company. I set the link Master Fields and links child Fields property of the subform to the companyId. Basically, I set it up like this.

In theory, I would think this would mean that when I change the value in the combobox the subform should show the subscription information for that company. It isn't working though- the subform always shows all the data in the companySubscription view, no matter what the combobox is set to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千年*琉璃梦 2024-10-01 04:54:23

找到了答案 - 来自另一个项目的一些代码有帮助:

Private Sub cmbSub_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[subID] = " & str(Nz(Me![cmbSub], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

并且必须针对 ADP 对其进行修改(感谢 此帖子!)

Private Sub ChooseCo_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As ADODB.Recordset

    Set rs = Me.Recordset.Clone
    rs.Find "[companyId] = " & Str(Nz(Me![ChooseCo], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Found the answer- had some code from another project that helped:

Private Sub cmbSub_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[subID] = " & str(Nz(Me![cmbSub], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

And had to modify it for an ADP (thanks to this post!)

Private Sub ChooseCo_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As ADODB.Recordset

    Set rs = Me.Recordset.Clone
    rs.Find "[companyId] = " & Str(Nz(Me![ChooseCo], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文