Solved

Ms Access DLookup with multi criteria and a Null value

Posted on 2014-10-30
5
828 Views
Last Modified: 2014-10-30
Hello all,

I can not figure out what I am doing wrong with this syntax. I know that I am screwing thing up when filtering data [RemovedBy] for Null only data. My guess is that I am missing or miss placed quotation marks. Help!!!!

DLookup("LotNumber","CM_SOLUTION_USAGE", "[Station] = " & [Forms]![Station Replenishment]![Station] & " And [Solution] =  " & [Forms]![Station Replenishment]![cmbSolution]  & " And [RemovedBy]Is Null")

Thank you!!!
0
Comment
Question by:Cobra967
  • 2
  • 2
5 Comments
 
LVL 84
ID: 40413590
Is Station or Solution are Text fields:

DLookup("LotNumber","CM_SOLUTION_USAGE", "[Station] = '" & [Forms]![Station Replenishment]![Station] & "' And [Solution] =  '" & [Forms]![Station Replenishment]![cmbSolution]  & "' And IsNull([RemovedBy])")
0
 

Author Comment

by:Cobra967
ID: 40413607
[Station] is a number, [Solution] is a text and [RemovedBy] is a text.
0
 

Author Comment

by:Cobra967
ID: 40413677
Thank you Scott but it does not work yet, I get error Run-time 3464.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 400 total points
ID: 40413825
Try this:

DLookup("LotNumber","CM_SOLUTION_USAGE", "[Station] = " & [Forms]![Station Replenishment]![Station] & " And [Solution] =  '" & [Forms]![Station Replenishment]![cmbSolution]  & "' And IsNull([RemovedBy])")
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 100 total points
ID: 40413857
If you are still having syntax issues, create a string variable and populate it outside the DLookup().  That way you can look at it directly and see that the quotes are where they should be.

Dim strWhere as String
strWhere = "[Station] = " & [Forms]![Station Replenishment]![Station] & " And [Solution] =  '" & [Forms]![Station Replenishment]![cmbSolution]  & "' And [RemovedBy] Is Null"
DLookup("LotNumber","CM_SOLUTION_USAGE", strWhere)

Also, if you are running the code within the form [Station Replenishment], you can shorten the expression by using the Me. reference which also makes it easier to read.

strWhere = "[Station] = " & Me.Station & " And [Solution] =  '" & Me.cmbSolution  & "' And [RemovedBy] Is Null"
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now