Solved

Is Null

Posted on 2011-02-15
5
361 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 500 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

733 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