?
Solved

Is Null

Posted on 2011-02-15
5
Medium Priority
?
380 Views
Last Modified: 2012-05-11
Experts,

I have a report with a form to query the records.
I thought that my criteria would include records that have a null for [CurrencyName] but if the [CurrencyName] is null in the tblCurrencyExchange then it will exclude those records.  If I select a [CurrencyName] from the cbo then it will include them.  

I have this on [CurrrencyName] Like "*" & Nz([forms]![frmLCIssuedQryType]![cboCurrency],"") & "*"
if I remove the Like statement then the ones with Null for CurrencyName will appear.  

do you see anything wrong here:
thank you

SELECT tblLetterOfCredit.DateOfIssueSB, tblLCTypeDropbox.LCType, tblCurrencyExchange.CurrencyName, tblEndUser.[End User], tblCurrencyExchange.Currency, tblLetterOfCredit.BankGTIssueDate, tblLetterOfCredit.Amount, Projects.ID, tblLetterOfCredit.LetterOfCreditID, tblCountry.Country, tblCurrencyExchange.CurrencyID, tblLetterOfCredit.EndUserID, tblCurrencyExchange.ExchangeRate, Projects.contractingEntity, tblLetterOfCredit.AdvisingBank, tblLetterOfCredit.LocalBankName, tblLetterOfCredit.lcno, Projects.[project name], tblBanks.BankName, Projects.Status2, IIf(IsNull([tblLetterOfCredit].[DateOfIssueSB]),"Not Issued (No Issue Date Entered)","Issued LC's") AS MyGroup FROM tblCurrencyExchange RIGHT JOIN (Projects RIGHT JOIN ((((tblLetterOfCredit LEFT JOIN tblCountry ON tblLetterOfCredit.Country = tblCountry.CntryID) LEFT JOIN tblBanks ON tblLetterOfCredit.BankID = tblBanks.BankID) LEFT JOIN tblEndUser ON tblLetterOfCredit.EndUserID = tblEndUser.EndUserID) LEFT JOIN tblLCTypeDropbox ON tblLetterOfCredit.LCType = tblLCTypeDropbox.ID) ON Projects.ID = tblLetterOfCredit.ProjectID)

ON tblCurrencyExchange.CurrencyID = tblLetterOfCredit.Currency WHERE (((tblLCTypeDropbox.LCType) Like "*" & Nz([forms]![frmLCIssuedQryType]![txtLCtype],"") & "*")

AND ((tblCurrencyExchange.CurrencyName) Like "*" & Nz([forms]![frmLCIssuedQryType]![cboCurrency],"") & "*") AND ((tblEndUser.[End User]) Like "*" & Nz([forms]![frmLCIssuedQryType]![txtEndUser],"") & "*"));
0
Comment
Question by:pdvsa
[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 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 34901791
Here is the general idea:

SELECT Table1.*
FROM Table1
WHERE (((Table1.CurrrencyName)=[Forms]![Form1]![combo32])) OR (((IsNull([CurrrencyName]))=True));

mx
0
 
LVL 7

Expert Comment

by:mmr159
ID: 34901840
> do you see anything wrong here

Your query is very difficult to interpret.  So much so that I went and cleaned it up a little.


SELECT loc.DateOfIssueSB, 
	lct.LCType, 
	ce.CurrencyName, 
	eu.[End User], 
	ce.Currency, 
	loc.BankGTIssueDate, 
	loc.Amount, 
	proj.ID, 
	loc.LetterOfCreditID, 
	c.Country, 
	ce.CurrencyID, 
	loc.EndUserID, 
	ce.ExchangeRate, 
	proj.contractingEntity, 
	loc.AdvisingBank, 
	loc.LocalBankName, 
	loc.lcno, 
	proj.[project name], 
	b.BankName, 
	proj.Status2, 
	IIf(
		IsNull(loc.DateOfIssueSB),
		"Not Issued (No Issue Date Entered)",
		"Issued LC's"
		) AS MyGroup
FROM tblCurrencyExchange AS ce RIGHT JOIN (
	Projects AS proj RIGHT JOIN (
	(((
	tblLetterOfCredit AS loc LEFT JOIN tblCountry AS c
		ON loc.Country = c.CntryID
	) LEFT JOIN tblBanks AS b
		ON loc.BankID = b.BankID
	) LEFT JOIN tblEndUser AS eu
		ON loc.EndUserID = eu.EndUserID
	) LEFT JOIN tblLCTypeDropbox AS lct
		ON loc.LCType = lct.ID
	) ON proj.ID = loc.ProjectID
	) ON ce.CurrencyID = loc.Currency
WHERE (((lct.LCType) Like "*" & Nz([forms]![frmLCIssuedQryType]![txtLCtype],"") & "*")
	AND ((ce.CurrencyName) Like "*" & Nz([forms]![frmLCIssuedQryType]![cboCurrency],"") & "*")
	AND ((eu.[End User]) Like "*" & Nz([forms]![frmLCIssuedQryType]![txtEndUser],"") & "*"));

Open in new window

0
 

Author Comment

by:pdvsa
ID: 34901963
I had to change [CurrencyName] to ((IsNull([forms]![frmLCIssuedQryType]![cboCurrency]))=True));

because if I left it as
WHERE (((Table1.CurrrencyName)=[Forms]![Form1]![combo32])) OR (((IsNull([CurrrencyName]))=True));
A msgbox appeared asking for [CurrencyName]

It seems to work but I am a little confused because I woudl think that I woudl need the [CurrencyName] with criteria as Null and not on cboCurrency.

What do you think?
0
 

Author Closing Comment

by:pdvsa
ID: 34905689
Thanks...
0
 
LVL 75
ID: 34908667
You are welcome ...

mx
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

741 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