Return a Value from table when...

Dragonchaser

Registered User.
Local time
Yesterday, 23:43
Joined
May 15, 2007
Messages
31
Hi All,

I would like have a control in a form return a value when 3 fields in the form match 3 different fields in a table. The value a want returned is the 4th field in the same record as the 3 matching criteria from the form. I've tried a long dlookup expression with no luck. It always returns the value in the first row.

=DLookUp("[FlangeWidth]","[SingleChamberPipeCalculationData]","[FlangeSize] =" & [Forms]![SingleChamberForm]![MeterRunSize] & And "[Pressure] = " & [Forms]![SingleChamberForm]![PressureRating] & " And [FlangeType]= '" & [Forms]![SingleChamberForm]![UpstreamFitting] & "'")

[MeterRunSize] & [Pressure] are numeric and [UpstreamFitting] is a string.
I've attached a picture as they're worth 1000 words.
Am I using the wrong function all together?

Any light anyone can shed on what I'm doing wrong would be greatly appreciated.

Best Regards,

Mark
 

Attachments

  • picDlookup.JPG
    picDlookup.JPG
    40.4 KB · Views: 118
Your 1st " And " was outside of the quotes.
Code:
=DLookUp("[FlangeWidth]","[SingleChamberPipeCalculationData]", _
"[FlangeSize] = " & [Forms]![SingleChamberForm]![MeterRunSize] & _
" And [Pressure] = " & [Forms]![SingleChamberForm]![PressureRating] & _
" And [FlangeType] = '" & [Forms]![SingleChamberForm]![UpstreamFitting] & "'")
 
Thanks RG.
Fixed the syntax, but now it doesn't return anything.
Will this function only work on new form records?
Or should change all the existing records?
 
DLookup() returns a Null if no match is found.
 
But it searches all the records in the table, correct?
 

Users who are viewing this thread

Back
Top Bottom