Solved

Is Null

Posted on 2011-02-15
5
333 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
  • 2
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

864 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

21 Experts available now in Live!

Get 1:1 Help Now