DLookup Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Howdy -

I have the following in a query field:

Expr1: DLookUp("[plAge65Units]","tblPlans","[plName] =
[qryConversions]![cePlan]")

plAge65Units & plName come from the table tblPlans
cePlan is located in the same query (qryConversions) that I am attempting to
put this field in.

I keep getting an error saying that it does not recognize the field
[qryConversions]![cePlan], yet it is clearly in the query. The whole
expression lies on the same line & is not broken up as above.

Can anyone offer any hope/help? Thanks.
 
Howdy -

I have the following in a query field:

Expr1: DLookUp("[plAge65Units]","tblPlans","[plName] =
[qryConversions]![cePlan]")

plAge65Units & plName come from the table tblPlans
cePlan is located in the same query (qryConversions) that I am attempting to
put this field in.

I keep getting an error saying that it does not recognize the field
[qryConversions]![cePlan], yet it is clearly in the query. The whole
expression lies on the same line & is not broken up as above.

Can anyone offer any hope/help? Thanks.

Two issues:

The ! delimiter is not suitable for table/query fields; use . instead;

you need to pull the criterion out of the quoted string and delimit it
with quotemarks. Assuming that plName is a Text field which might
contain an apostrophe (O'Niell for example), try


MeaningfulName: DLookUp("[plAge65Units]","tblPlans","[plName] = " &
Chr(34) & [qryConversions].[cePlan] & Chr(34))

Chr(34) is the " character needed to delimit string criteria.

One question: Why use DLookUp, rather than just joining qryConversions
to your Query? (You probably have a good reason to do so, but I did
want to at least raise the possibliity).
 
Howdy -

I have the following in a query field:

Expr1: DLookUp("[plAge65Units]","tblPlans","[plName] =
[qryConversions]![cePlan]")

plAge65Units & plName come from the table tblPlans
cePlan is located in the same query (qryConversions) that I am attempting to
put this field in.

I keep getting an error saying that it does not recognize the field
[qryConversions]![cePlan], yet it is clearly in the query. The whole
expression lies on the same line & is not broken up as above.

Can anyone offer any hope/help? Thanks.

Is the [cePlan] text datatype or number?

If it's Text...
Expr1: DLookUp("[plAge65Units]","tblPlans","[plName] = '" & [cePlan] &
"'")

If it's Number..
Expr1: DLookUp("[plAge65Units]","tblPlans","[plName] = " & [cePlan] )
 
Thank you so much!!! The field was a text and it works now. You have no
idea how much I appreciate you all!
 
Back
Top