Multiple Criteria in Combo Box Dlookup

G

Guest

I have the following code in the AfterUpdate of a combo box. Ref_Part_NHL is
another combo that I'm populating. I'm doing it this way because the first
value will show as the default value in the Ref_Part_NHL combo box. RefPart
is a field on the open form. This is working perfect. I need some
additional criteria, however.

Me.Ref_Part_NHL = DLookup("[AS Part#]", "ExcelARefParts", "[PART#] = '" &
[RefPart] & "'")

How can I add to the above code to only pick the records in the
ExcelARefParts table where Part# = RefPart (which it's currently doing) And
Variable <> "" And Part# <> AS Part#? Variable (number field) and AS Part#
(text field) are also fields in the ExcelARefParts table. Thanks much!
Alex
 
D

Douglas J Steele

Me.Ref_Part_NHL = DLookup("[AS Part#]", "ExcelARefParts", "[PART#] = '" &
[RefPart] & "' And Variable <> '' And [PART#] <> [AS Part#]")

Note that I've used two single quotes in the comparison to Variable
(exagerated, it's Variable <> ' ' ) You could also use:

Me.Ref_Part_NHL = DLookup("[AS Part#]", "ExcelARefParts", "[PART#] = '" &
[RefPart] & "' And Variable <> """" And [PART#] <> [AS Part#]")

(where that's 4 double quotes in a row)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top