Between parameter with null values (1 Viewer)

jderrig

Registered User.
Local time
Today, 04:56
Joined
Nov 11, 2012
Messages
15
I am trying to alter this parameter to bring back all records if either beginningsalesrange or ending salesrange is left blank. I can't quite get it right. Thanks

Between [forms]![frmState]![BeginningSalesRange] And [Forms]![frmState]![EndingSalesRange]
 

plog

Banishment Pending
Local time
Today, 04:56
Joined
May 11, 2011
Messages
11,668
I would suggest moving the criteria into a field. It would look like this:

Include: Iif(Isnull([forms]![frmState]![BeginningSalesRange]) OR IsNull([Forms]![frmState]![EndingSalesRange]) OR Between [forms]![frmState]![BeginningSalesRange] And [Forms]![frmState]![EndingSalesRange], 1,0)

Then in the criteria section under that field, you put in 1. That way if it meets any of your 3 criteria the result is included.
 

GSSDevelopment

PHP Guru
Local time
Today, 05:56
Joined
Dec 31, 2012
Messages
58
Try this:

Code:
WHERE ISNULL([Forms]![frmState]![BeginningSalesRange]) OR ISNULL([Forms]![frmState]![EndingSalesRange])
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:56
Joined
Aug 30, 2003
Messages
36,133
An alternative is the NZ() function on each form reference, each with a date before/after any possible date in the data.
 

jderrig

Registered User.
Local time
Today, 04:56
Joined
Nov 11, 2012
Messages
15
Thanks for the replys but I am getting invalid syntax on both of these:

Include: Iif(Isnull([forms]![frmState]![BeginningSalesRange]) OR IsNull([Forms]![frmState]![EndingSalesRange]) OR Between [forms]![frmState]![BeginningSalesRange] And [Forms]![frmState]![EndingSalesRange], 1,0)

WHERE ISNULL([Forms]![frmState]![BeginningSalesRange]) OR ISNULL([Forms]![frmState]![EndingSalesRange])
 

plog

Banishment Pending
Local time
Today, 04:56
Joined
May 11, 2011
Messages
11,668
Post the full SQL that you have.
 

jderrig

Registered User.
Local time
Today, 04:56
Joined
Nov 11, 2012
Messages
15
SELECT Profitable.CHSAcctNo, Profitable.GrossRevenue, Profitable.FarmSupplyRev, Profitable.GrainRev, Profitable.Expenses, Profitable.OtherIncome, Profitable.OtherExp, Profitable.CHSAcctNo AS CountOfCHSAcctNo, Profitable.City, Profitable.State, Profitable.[MS/CO], Profitable.[Grain/FS], Profitable.FYE, Profitable.MemberEquity, Profitable.WorkingCapital, Profitable.LocalSavings, Profitable.TotalSavings, Profitable.TDtoLE, Profitable.ROLE, Profitable.BSMId, Profitable.[Acct name], Profitable.TopAccount, Profitable.NetLS, Profitable.TTLSales, Profitable.TotalAssets, Profitable.CurrentAssets, Profitable.FixedAssets, Profitable.InvOtherOrgan, Profitable.OtherAssets, Profitable.CurrentLiabilities, Profitable.LongTermDebt, Profitable.ServiceRev, Profitable.[Income/LossfromLLC], Profitable.[-/+SaleAssetorInv], Profitable.Patronage, Profitable.IncomeTaxes, Profitable.Sales, Profitable.Year, Profitable.RetainedSavings, Profitable.GrainBushels, Profitable.[Salary/BenefitExp], Profitable.Depreciation, Profitable.CCMAmoritization, Profitable.EBITDA, Profitable.InterestExp, Nz([memberequity],0)-Nz([invotherorgan],0) AS LocalEquity, [Forms]![frmState]![txtQueryCriteria] AS Expr1, Profitable.OtherLTL, Profitable.EBITDARevised, Profitable.EBITRevised, Profitable.NetAssets
FROM Profitable
WHERE (((Profitable.CHSAcctNo) Like [forms]![frmState]![select Account] & "*" And (Profitable.CHSAcctNo) Like [forms]![frmState]![select Account] & "*") AND ((Profitable.[Grain/FS]) Like [Forms]![frmState]![Select Type] & "*") AND ((Profitable.BSMId) Like [Forms]![frmState]![BDMList] & "*") AND ((Profitable.TopAccount) Like [Forms]![frmState]![TopAccount] & "*") AND ((Profitable.Year) Between [forms]![frmState]![lstYear] And [forms]![frmState]![2ndYear]) AND (([Forms]![frmState]![txtQueryCriteria]) Like "*;" & [State] & ";*"));
 

Brianwarnock

Retired
Local time
Today, 10:56
Joined
Jun 2, 2003
Messages
12,701
FWIW. I think PBaldy's solution is the only viable one, you cannot have the Between And in the Iif , and I don't see how GSS tackles the whole problem.

Brian
 

jderrig

Registered User.
Local time
Today, 04:56
Joined
Nov 11, 2012
Messages
15
OK, thanks for that suggestion. I am unclear though on how the NZ function would work in this situation. I am trying to filter via a sales range and not date for this parameter.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:56
Joined
Aug 30, 2003
Messages
36,133
Like

Between Nz([forms]![frmState]![lstYear], 1901) And Nz([forms]![frmState]![2ndYear], 2029)
 

jderrig

Registered User.
Local time
Today, 04:56
Joined
Nov 11, 2012
Messages
15
Maybe I am confused here...or I'm not understanding. I have the years set for the parameter fine. It's that I want to filter sales ranges. The user will enter a sales range to pull the accounts between those ranges.

Beginning Sales: 100,000,000
Ending Sales: 500,000,000

The results would be all those that have sales between 100M and 500M- which I have no issues with but I would like to have the option of leaving those two fields blank so that the results will show all accounts regardless of sales.



Like

Between Nz([forms]![frmState]![lstYear], 1901) And Nz([forms]![frmState]![2ndYear], 2029)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 02:56
Joined
Aug 30, 2003
Messages
36,133
I'm simply demonstrating the concept I had in mind. You can apply it as desired to the appropriate field, with the appropriate form references and the appropriate values.
 

Users who are viewing this thread

Top Bottom