Using parameter in query to specify null/not null records

Using parameter in query to specify null/not null records

Post by Amy Blanke » Thu, 24 Jan 2008 03:54:45


I have this query:

Select Max(SessionID) FROM Session WHERE ObjectID = [Enter CatID] And
LevelID = 2 And [EndTime] Is Null

I want to be able to use a parameter to be able to switch at will from

AND [EndTime] Is Null

to

AND [EndTime] Is NOT Null

Obviously, this is to be able to return values from only closed sessions or
from only open sessions. I haven't encountered this syntax before in my
work with Access, so I am a bit unsure as to how to phrase this.

Does anyone have any ideas?

Thanks;

Amy
 
 
 

Using parameter in query to specify null/not null records

Post by John Spenc » Thu, 24 Jan 2008 04:54:55

You M_I_G_H_T be able to do that with the following: Enter anything at
all in response to the prompt if you want non-null values

Select Max(SessionID)
FROM Session
WHERE ObjectID = [Enter CatID]
And LevelID = 2
And (([EndTime] Is Null And [Leave Blank for Null] is Null)
OR ([EndTime] is Not Null and [Leave Blank for Null] is Not Null))


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

 
 
 

Using parameter in query to specify null/not null records

Post by Amy Blanke » Thu, 24 Jan 2008 04:58:14

Yes, I wound up doing something similar.

Thanks;

Amy