?
Solved

Ms Access DLookup with multi criteria and a Null value

Posted on 2014-10-30
5
Medium Priority
?
1,046 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 85
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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1600 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 38

Assisted Solution

by:PatHartman
PatHartman earned 400 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

801 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