Question : Dlookup getting #name Error with subform

I have a main form with the following fields:
[birthday] - (they enter information),
[current age]  - DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd"))
[Month] - DatePart("m",[DOB])
[Year] - DatePart("yyyy",[DOB])

I have a tLifeRate table with the following:
Current_Age        Rate       Amount
<70                       $1.45      10,000.00
70 - 74                  $0.90      $6,500.00
75-79                    $0.65      $4,500.00
80                         $0.44      $3,000.00

I have a life subform with a field of [Rate] on it. When the Life subform is active I am trying to have the [rate] do a dlookup based on the [current_age] and return the rate amount they need.

This is my function I am having probelm with.
=IIf(Forms!fInputRetiree!Current_Age<70,DLookUp("[Rate]","tLifeRate","[Current_Age]=[Forms]![fInputLife]![ Current_Age]"),
IIf(Forms!fInputRetiree!Current_Age>=70 And fInputRetiree!Current_Age<=74,DLookUp("[Rate]","tLifeRate","[Current_Age]=[Forms]![fInputLife]![Current_Age]"),
IIf(Forms!fInputRetiree!Current_Age>75 And fInputRetiree!Current_Age<=79,DLookUp("[Rate]"," tLifeRate ","[Current_Age]=[Forms]![ fInputLife]![Current_Age]"),
IIf(Forms!fInputRetiree!Current_Age>80,DLookUp("[Rate]"," tLifeRate ","[Current_Age]=[Forms]![ fInputLife]![Current_Age]")))))

Answer : Dlookup getting #name Error with subform

Try This


=IIf(Forms!fInputRetiree_Information!Current_Age<70,DLookUp("[Rate]","tLifeRate","[Current_Age]= '" & "<70" & "'"),IIf(Forms!fInputRetiree_Information!Current_Age>69 And Forms!fInputRetiree_Information!Current_Age<75,DLookUp("[Rate]","tLifeRate","[Current_Age]= '" & "70-74" & "'"),IIf(Forms!fInputRetiree_Information!Current_Age>74 And Forms!fInputRetiree_Information!Current_Age<80,DLookUp("[Rate]","tLifeRate","[Current_Age]= '" & "75-79" & "'"),IIf(Forms!fInputRetiree_Information!Current_Age>79,DLookUp("[Rate]","tLifeRate","[Current_Age]= '" & "80" & "'"),0))))

You will also need to put

Me.fInputLife.Requery

in the AfterUpdate event of the Birthdate field on your main form to update the changes in your life subform.

By the way  <I know it has to be something simple> ....  It was.
You had forgotton the "_Information" when referencing your form ie
Forms!fInputRetiree   needed to be   Forms!fInputRetiree_Information

Leigh



Random Solutions  
 
programming4us programming4us