A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Easy query criteria question



 
 
Thread Tools Display Modes
  #1  
Old June 26th, 2008, 07:14 PM posted to microsoft.public.access.queries
Bongard
external usenet poster
 
Posts: 122
Default Easy query criteria question

For some reason I can't figure this out. I have two fields in my query
(relevant for this question). [Port Num] (numeric field) and [Type]
(text). I need my criteria to say that If [Port Num] = 210 then [Type]
"F". What is the suntax to get this to work in the criteria line of
the query? I've tried putting the field [Type] and having the criteria
be Iif([Port Num] = 210, "F") but that doesn't seem to work.

Any help would be appreciated
Thanks,
Brian
  #2  
Old June 26th, 2008, 08:04 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Easy query criteria question

Field: PortNum
Criteria: 210

Field: Type
Criteria: "F"

That will give you all records except those that have a Portnum of 210 and
Type of "F" with the exception that records with null values will also be
eliminated.

IF you want to get the records with a null value in one or the other field
then you need to use two more lines of criteria where you enter Is Not Null on
line 2 under PortNum and Is Not Null on line 3 under Type.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Bongard wrote:
For some reason I can't figure this out. I have two fields in my query
(relevant for this question). [Port Num] (numeric field) and [Type]
(text). I need my criteria to say that If [Port Num] = 210 then [Type]
"F". What is the suntax to get this to work in the criteria line of
the query? I've tried putting the field [Type] and having the criteria
be Iif([Port Num] = 210, "F") but that doesn't seem to work.

Any help would be appreciated
Thanks,
Brian

  #3  
Old June 26th, 2008, 08:36 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Easy query criteria question

Bongard wrote:

For some reason I can't figure this out. I have two fields in my query
(relevant for this question). [Port Num] (numeric field) and [Type]
(text). I need my criteria to say that If [Port Num] = 210 then [Type]
"F". What is the suntax to get this to work in the criteria line of
the query? I've tried putting the field [Type] and having the criteria
be Iif([Port Num] = 210, "F") but that doesn't seem to work.



Try adding a calculated field to the query:
([Port Num] = 210 And [Type] = "F")
and set its criteria to:
False

--
Marsh
MVP [MS Access]
  #4  
Old July 1st, 2008, 02:50 PM posted to microsoft.public.access.queries
Bongard
external usenet poster
 
Posts: 122
Default Easy query criteria question

On Jun 26, 2:36*pm, Marshall Barton wrote:
Bongard wrote:
For some reason I can't figure this out. I have two fields in my query
(relevant for this question). [Port Num] (numeric field) and [Type]
(text). I need my criteria to say that If [Port Num] = 210 then [Type]
"F". What is the suntax to get this to work in the criteria line of
the query? I've tried putting the field [Type] and having the criteria
be Iif([Port Num] = 210, "F") but that doesn't seem to work.


Try adding a calculated field to the query:
* * * * ([Port Num] = 210 And [Type] = "F")
and set its criteria to:
* * * * False

--
Marsh
MVP [MS Access]


Thank you Marshall this worked perfectly. John I had lots of other
criteria in the query and could not only include Portfolio 210 so that
suggestion would not have worked in my case.

Thanks for your help guys,
Brian
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.