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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup Using Multiple Criteria

Status
Not open for further replies.

tammy23

Technical User
Aug 3, 2010
17
US
Access 2000, Windows XP

I need to lookup an entry in WellLogDetails based on two criteria in Report2 and all three of the following codes return errors....any suggestions?

'a = DLookup("[FileLoc]", "WellLogDetails", "[Well]=Reports!Report2![Well]" And "[ID]=Reports!Report2![ID]")

'a = DLookup("[FileLoc]", "WellLogDetails", "[Well]='" & Reports!Report2![Well] & "' AND [ID]= '" & Reports!Report2![ID] & "'")

a = DLookup("[FileLoc]", "WellLogDetails", "[Well]=[Reports]![Report2]![Well] and [ID]=[Reports]![Report2]![ID]")
 
Is this code or a control source of a text box?
Are both Well and ID bound to controls in your report?
If this is code, is a a string variable?
Are both Well and ID numeric?

Assuming both fields are numeric...
Have you considered a text box with a control source of:
Code:
=DLookup("[FileLoc]", "WellLogDetails", "[Well]=" & [Well] & " And [ID]=" & [ID])
If this is in code (for some reason) make sure the fields are bound to controls and try:
Code:
a=DLookup("[FileLoc]", "WellLogDetails", "[Well]=" & Me.[Well] & " And [ID]=" & Me.[ID])



Duane
Hook'D on Access
MS Access MVP
 
Thanks for the the help :)

ID is numeric, Well is not. Remou's code worked great:

a = DLookup("[FileLoc]", "WellLogDetails", "[Well]=Reports!Report2![Well] And [ID]=Reports!Report2![ID]")

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top