DLookup 表達式總是返回相同的記錄 (DLookup expression always returning the same record)


問題描述

DLookup 表達式總是返回相同的記錄 (DLookup expression always returning the same record)

我有一個名為 ProductionReportLandscape 的表單,其中有一個名為 ProductMasterData 的表設置為其記錄源。

有一個名為 CartonDateFormat 的文本框控件(從 ProductMasterData 表中獲取其值)以及 上的未綁定文本框控件ProductionReportLandscape

數據庫中還有一個名為DateCodes的表。DateCodes 表中的每條記錄都有一個名為 OutputDateCode 的字段。CartonDateFormat 是一個數值,可以是 1‑36 之間的任意數字。

我試圖讓未綁定的文本框控件從 OutputDateCode 對應於每條記錄的 CartonDateFormat

例如,如果 CartonDateFormat 為 13,那麼我希望文本框控件顯示 DateCodes 的記錄 13 中的 OutputDateCode 表。如果 CartonDateCode 是 14,那麼我希望文本框顯示來自記錄 14 的 OutputDateCode 等每個數字 1‑36。

我已經為未綁定的文本框構建了一個 DLookup 表達式控制源屬性,但它總是從第一條記錄返回 OutputDateCode 而不管什麼記錄被選中。

我無法弄清楚如何更改表達式以達到預期的結果。有什麼想法嗎?

=DLookUp("OutputDateCode","DateCodes","[CartonDateFormat] =" & [CartonDateFormat])

參考解法

方法 1:

You reference names CartonDateFormat and CartonDateCode. You indicate CartonDateFormat is a textbox but not what CartonDateCode is.

Unless DateCodes has field CartonDateFormat with carton codes, DLookup cannot find match.

The DLookup needs to use name of field in DateCodes table that has carton codes. If that is CartonDateCode, then change DLookup to:

=DLookUp("OutputDateCode","DateCodes","[CartonDateCode] =" & [CartonDateFormat])

(by Kyra LedkinsJune7)

參考文件

  1. DLookup expression always returning the same record (CC BY‑SA 2.5/3.0/4.0)

#ms-access-forms #dlookup #ms-access-2010 #ms-access






相關問題

DLookup 表達式總是返回相同的記錄 (DLookup expression always returning the same record)

MS-Access VBA - 如何將文本框使用的當前查詢字段名稱分配給變量 (MS-Access VBA - How to assign the current query field name used by a textbox to a variable)

MS Access 錯誤 3188:無法更新;當前被這台機器上的另一個會話鎖定 (MS Access Error 3188: Could not update; currently locked by another session on this machine)

將文本框值分配給多個表/查詢字段值 (Assigning a textbox value to a multiple table/query field values)

從訪問表單的文本字段傳遞開始和結束日期參數 (Pass start and end date parameter from text field of access form)

如何根據來自兩個組合框的輸入隱藏/取消隱藏子表單? (How do I hide/unhide a subform based on the input from two comboboxes?)

ms訪問表單:組合框到多選下拉菜單 (ms access form: combobox to multiselect dropdown menu)

訪問表單宏 Where 條件 (Access Form Macro Where Condition)

(Microsoft Access) 如何輸入多個新記錄,其中 5 個字段中有 2 個被重置 ((Microsoft Access) How to Input multiple new records with 2 out of 5 fields from being reset)

帶有“新記錄”按鈕的更新前 (BeforeUpdate with a "new record" button)

MS Access 表單日期/時間輸入問題 (MS Access Forms Date/Time Entry Trouble)







留言討論