Syntax Error on DLookup

P

Pamela

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela
 
T

theDBguy

Hi Pamela,

Not sure if this will work but try this syntax:

Me.Parent.Form!Measurements

Hope that helps...
 
P

Pamela

Hi DBguy,
Something I just realized is that I ONLY get this Syntax Error when the
field is skipped which is then Null. I do have an expression set in my query
to give a result for a null value but I think that's what's throwing this
off. Any suggestions for how to handle that??
 
D

Dorian

What kind of data is in Measurements?
If it is text rather than a number, you need to include the value in your
DLookup in single quotes. e.g.
"Measurements = '" Me.Parent!Measurements & "'")

I'd also lookup in Access help on Subforms especially how to refer to one
subforms controls from another.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
P

Pamela

I tried that, Dorian, but it isn't giving me anything now - just as though
that code isn't there which perhaps is better than an error...LOL But it
isn't returning anything for that piece of code. The query to which this is
referring has an expression that if the Measurements value is null, then text
is returned stating that there are no measurements but otherwise, text is
concatenated w/ the text in my measurements control stating that the height
of the damage is __ inches.
Any other ideas???
 
P

Pamela

Hi Linq,
The field is text, and I tried changing it to include the extra " ' "s that
you instructed and someone else instructed but I'm still not getting it to
work. With that, the code doesn't give an error but it literally returns
blank. Note though that my original code works perfectly IF there's a value
entered. I'm only having this problem if the field is null. Any additional
help would be really great!
 
T

theDBguy

Hi Pamela,

In that case, you could probably use an IIf() statement. For example:

=IIf(<test for skipped record>, "Record Skipped", DLookup(...))

Hope that helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top