如何查找要在带有DLOOKUP的表单中使用的表字段?以下是我一直在使用的,但不断获得#TYPE!错误。
=DLookUp("[ProductName]","[TblProduct]","[TblProduct].[ProductCode] =" & Str([ProductCode_Text].[Text])
答案 0 :(得分:0)
您的产品代码需要用单引号括起来:
=DLookUp("[ProductName]","[TblProduct]","[TblProduct].[ProductCode] = '" & Str([ProductCode_Text].[Text] & "'")
答案 1 :(得分:0)
非常感谢。我已经修改了代码并且它可以工作,但这是最有效的方法吗?
Private Sub Location_AfterUpdate()
Dim filteritem As String
DoCmd.OpenTable "item_Detail"
Me.Units_in_UOM.Visible = True
filteritem = "[ItemId]=" & "'" & Me.Item & "'"
MsgBox (filteritem) ' just for testing need to delete
Me.Units_in_UOM = DLookup("[QPC]", "[Item_Detail]", filteritem)
'Me.Units_in_UOM = DLookup("[QPC]", "[Item_Detail]", "[ItemId]=" & 'filteritem)
End Sub