Dlookup 依赖于标签/文本框

发布于 2024-10-31 09:06:35 字数 311 浏览 1 评论 0原文

我试图弄清楚如何使我的 Dlookup 函数看起来像其关联的标签和该标签的值。

我的例子是:

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]=LABEL CONTENT HERE")

最重要的是,我需要添加一个 Mid() 命令,如下所示:

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]=Mid("LABEL CONTENT HERE")")

I am trying to figure out how I can make my Dlookup function to look as its associated label and the value of that label.

My example is:

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]=LABEL CONTENT HERE")

And on top of that, I need to add a Mid() command for something like this:

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]=Mid("LABEL CONTENT HERE")")

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

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

发布评论

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

评论(2

下壹個目標 2024-11-07 09:06:35

如果附加了标签,您的文本框将有一组控件。

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]='" & Me.TextBox1.Controls(0).Caption & "'")

您必须确定表单上文本框的名称。我使用 TextBox1 作为示例。

Your textbox will have a set of controls if the label is attached.

=DLookup("[OfficeOf]","tblLocationMSTR","[LocationCode]='" & Me.TextBox1.Controls(0).Caption & "'")

You will have to determine the name of the textbox on your form. I used TextBox1 as an example.

墨落画卷 2024-11-07 09:06:35

将表单的 OnLoad 属性设置为 [Event procedure],然后在表单后面添加以下代码:

Private Sub Form_Load()
Dim Ctl As Control

    For Each Ctl In Me.Controls
        If Ctl.Tag = "some_text_used_as_a_flag" Then
            Ctl.ControlSource = "=DLookup(""[OfficeOf]"",""tblLocationMSTR"",""[LocationCode]=""" & Ctl.Controls(0).Caption & """)"
        End If
    Next Ctl
End Sub

我假设您需要一种方法来指定应动态更新哪些标签/文本框组合。您可以通过将每个文本框的 Tag 属性设置为某些特定文本来实现此目的,您可以在循环遍历控件时检查这些文本。

Set the form's OnLoad property to [Event Procedure] then add the following code behind the form:

Private Sub Form_Load()
Dim Ctl As Control

    For Each Ctl In Me.Controls
        If Ctl.Tag = "some_text_used_as_a_flag" Then
            Ctl.ControlSource = "=DLookup(""[OfficeOf]"",""tblLocationMSTR"",""[LocationCode]=""" & Ctl.Controls(0).Caption & """)"
        End If
    Next Ctl
End Sub

I assumed that you'll want a way to specify which label/textbox combos should be dynamically updated. You can do that by setting the Tag property of each textbox to some specific text that you can check when looping through the controls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文