Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup on multiple fields

Status
Not open for further replies.

davidbenz

Technical User
May 30, 2001
2
EC
I have 2 tables with multiple-field primary keys; each record is uniquely identified by both a FarmerID field and a Crop field.

On the form for Table2, I'd like a combo box to show what fertilizer was entered for that record in Table1. I've tried the following code:

Code:
=DLookup("[Fertilizer]","Table1","[FarmerID]AND[Crop] = " & [Forms]![Table2Form]![FarmerID]AND[Crop])

But the box only shows the fertilizer for the first record with that FarmerID in Table1, even when the crop is different.

Is there a way my form can show the correct fertilizer for each farmer/crop in Table1? Thank you.
 
See if it's problem with the code:

=DLookup("[Fertilizer]","Table1","[FarmerID]= '" & [Forms]![Table2Form]![FarmerID]&"' AND [CROP] = '"& [Forms]![Table2Form]![[Crop] &"'")

Tin Tin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top