問題描述
訪問表單宏 Where 條件 (Access Form Macro Where Condition)
這是我在這裡的第一篇文章。有點像 Access 的新手,我搜索了論壇來回答我的問題並嘗試使用類似的答案來讓我的宏工作,但我有一個語法錯誤。
我想點擊 details
按鈕在一個表單 (Employee Profile
) 上,然後打開另一個表單 (Employee Training Records
),它將提取與當前員工檔案有關的記錄。
在我目前的 where 條件下:
="[st_no]=" & [st_no] & " AND [emp_id]='" & [emp_id] & "'"
我收到一個語法錯誤:
(missing operator) in query expression '[st_no ]=IEC 62841‑2‑5 AND [emp_id]='3"
我錯過了什麼?
參考解法
方法 1:
Since the field st_no
looks to be a string, you'll need to enclose the corresponding value with single or double quotes; conversely, since emp_id
looks to be an integer, you don't need the surrounding quotes.
As such, I would suggest:
="[st_no]='" & [st_no] & "' AND [emp_id]=" & [emp_id]
(by Jessica Radliff、Lee Mac)