0

I am attempting to lookup a variable that matches the two given criteria. Please see script below:

Dim usr As String
Dim pafa As String
usr = DLookup("UserID", "tt_CurrentUser")
pafa = DLookup("PassFail", "dbo_TestDetail", [WHERE "dbo_TestDetail.TestIndex" = " & Me!JobLU & " And "dbo_TestDetail.SN" = " & Me!SN & "])

As shown, pafa is the variable I am having issues with.

Run-time error '2465' pops up with a message reading "Manufacturing Test Manager can't find the field '|1' referred to in your expression".

When I hit Debug, line 4 is highlighted. " & Me!JobLU & " and " & Me!JobLU & " are both the correct values when I hover my mouse over the text.

What am I doing wrong when defining these two criteria?

Also, pafa is going to equal either "Fail" or Null.

Gustav
  • 53,498
  • 7
  • 29
  • 55
Adam S.
  • 3
  • 5

1 Answers1

0

Why do you use WHERE and the brackets? The quotations are also wrong. When doing concatenation you need to distinguish literal string and identifiers that need to be evaluated. Try

"dbo_TestDetail.TestIndex = " & Me!JobLU & " And dbo_TestDetail.SN = " & Me!SN

Hovering the mouse over expressions and see the correct evaluation doesn't mean that an outer expression is written correctly.

Dávid Laczkó
  • 1,091
  • 2
  • 6
  • 25