Using parameter in query to specify null/not null records

  • Thread starter Thread starter Amy Blankenship
  • Start date Start date
A

Amy Blankenship

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
 
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
..
 
Yes, I wound up doing something similar.

Thanks;

Amy

John Spencer said:
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
.

Amy Blankenship said:
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
 
Back
Top