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
Solved

Ms Access DLookup with multi criteria and a Null value

Posted on 2014-10-30
5
910 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 35

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

808 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