Using the Right function in a dlookup

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I am trying to lookup a field in a table and use the Right function at the
same time and I can't seem to get the syntax correct. Can someone please
help me? Thank you.

my code: If IsNull(DLookup("Orig_Qty", "Tm", Right("PRODUCTIONORDERID ='",
2) & Me![Work Order] & "'")) Then . . .

I need to compare only the two right characters in the productionorderid
field in the Tm table.
 
Alex said:
I am trying to lookup a field in a table and use the Right function at the
same time and I can't seem to get the syntax correct. Can someone please
help me? Thank you.

my code: If IsNull(DLookup("Orig_Qty", "Tm", Right("PRODUCTIONORDERID ='",
2) & Me![Work Order] & "'")) Then . . .

I need to compare only the two right characters in the productionorderid
field in the Tm table.


I'm not sure I understand. Do you want to match the rightmost 2 characters
of Tm.PRODUCTIONORDERID with the complete value of Me![Work Order] ? If so,
then I think this is what you want:

DLookup("Orig_Qty", "Tm", _
"Right(PRODUCTIONORDERID, 2) = '" & Me![Work Order] & "'")
 
Yes - thanks much. I thought I had tried that. Darn!!!

Dirk Goldgar said:
Alex said:
I am trying to lookup a field in a table and use the Right function at the
same time and I can't seem to get the syntax correct. Can someone please
help me? Thank you.

my code: If IsNull(DLookup("Orig_Qty", "Tm", Right("PRODUCTIONORDERID ='",
2) & Me![Work Order] & "'")) Then . . .

I need to compare only the two right characters in the productionorderid
field in the Tm table.


I'm not sure I understand. Do you want to match the rightmost 2 characters
of Tm.PRODUCTIONORDERID with the complete value of Me![Work Order] ? If so,
then I think this is what you want:

DLookup("Orig_Qty", "Tm", _
"Right(PRODUCTIONORDERID, 2) = '" & Me![Work Order] & "'")



--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top