试图从我的报告中的另一个表格中获取描述

时间:2012-10-08 10:55:09

标签: database vba ms-access

Private Sub Report_Open(Cancel As Integer)

Dim strResultDesc As String

strResultDesc = DLookup("Description", "[products/stock]", "[Product Code] = Me.txtResultPC.Value")

Text20.Value = strResultDesc

End Sub

这是我目前的代码,我收到一条错误消息,指出存在以下问题:

[Product Code] = Me.txtResultPC.Value

有人能发现什么吗?

更新:

也试过这种方法,

Private Sub Report_Open(Cancel As Integer)

Dim strResultDesc As String

strResultDesc = DLookup("Description", "[products/stock]", "[products/stock].[Product Code] = [Result PC]")

Me.Text20.Value = strResultDesc

End Sub

谢谢,

Bob P

1 个答案:

答案 0 :(得分:0)

您必须添加符号“&”。请参阅下面的示例。

strResultDesc = DLookup("Description", "[products/stock]", "[Product Code] =" & Me.txtResultPC.Value)