Aikistan wrote:
>
> I created your 1-field, 3-record table in a blank database and, in
> the debug window Immediate, I tried:
>
> DLookup("AField","Junk") Error expected =
> DLookup("[AField]","Junk") Error expected =
> DLookup("[AField]","[Junk]") Error expected =
> DLookup("AField","[Junk]") Error expected =
>
Sigh
DLookup is a function that returns a result. You cannot call it without
assigning the result to something, a variable or another method. That's what
the "Expected =" error is referring to.
Do this in the immediate window:
?DLookup("AField","Junk")
The "?" is shorthand for "Debug.Print" and what happens is that DLookup
passes its return result to the Print method which consumes it as it writes
it to the immediate window.
This will also work:
retval=DLookup("AField","Junk")
But you won't see a result. To see the result do this:
retval=DLookup("AField","Junk") : ? retval
The colon allows you to enter multiple statements on a single line so they
can both be executed as a single batch in the immediate window.