Solved

Is Null

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views 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 Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

747 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

11 Experts available now in Live!

Get 1:1 Help Now