rows in queries

K

kate

I have a query which will give two results from running a switch i.e iif
([Field date 1] = [date],"stm" iif [field date 2] = [date],"tmp"))

this will not give me both results what do i do ?????

Thankyou
 
A

Arvin Meyer [MVP]

You are trying to get both fields in 1 column. There are 2 possible syntaxs:

IIf([Date1]=[Date],"stm","tmp")

Or:

IIf([Date1]=[Date],"stm",IIF([Date2]=[Date],"tmp",""))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

The first expression, doesn't look at [Date2] at all. The second expression
will not even evaluate [Date2] if [Date1] is true.
 
K

kate

Hello Thankyou for that but i need both rows to show

Arvin Meyer said:
You are trying to get both fields in 1 column. There are 2 possible syntaxs:

IIf([Date1]=[Date],"stm","tmp")

Or:

IIf([Date1]=[Date],"stm",IIF([Date2]=[Date],"tmp",""))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

The first expression, doesn't look at [Date2] at all. The second expression
will not even evaluate [Date2] if [Date1] is true.
kate said:
I have a query which will give two results from running a switch i.e iif
([Field date 1] = [date],"stm" iif [field date 2] = [date],"tmp"))

this will not give me both results what do i do ?????

Thankyou
 
B

BruceM

If you are talking about rows in the query's datasheet view you are talking
about two separate records. On another point, is [Date] a field, or is it
today's date? If the former, Date is not a good name since it can be
confused with the function for finding today's date. It is what is known as
a reserved word in Access. If the latter, I believe it needs to be
[Date()].

kate said:
Hello Thankyou for that but i need both rows to show

Arvin Meyer said:
You are trying to get both fields in 1 column. There are 2 possible
syntaxs:

IIf([Date1]=[Date],"stm","tmp")

Or:

IIf([Date1]=[Date],"stm",IIF([Date2]=[Date],"tmp",""))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

The first expression, doesn't look at [Date2] at all. The second
expression
will not even evaluate [Date2] if [Date1] is true.
kate said:
I have a query which will give two results from running a switch i.e
iif
([Field date 1] = [date],"stm" iif [field date 2] = [date],"tmp"))

this will not give me both results what do i do ?????

Thankyou
 
K

kate

I am sorry I am not trying to confuse anyone.
I have Fields in a query ok one is called [date for ogd] another is called
[date for stm] and another called [date for tmp].I would like to run a query
in a new field that says iif [a date i put in a parameter field] = [date for
ogd], "ogd",iif [a date i put in a parameter field]= [date for stm],"stm")

this is an inputted date [a date i put in a parameter field]

If this date matches both criteria I want to see both but not like "ogdstm"
i require it to give me to rows


I hope this makes sense
thankyou

BruceM said:
If you are talking about rows in the query's datasheet view you are talking
about two separate records. On another point, is [Date] a field, or is it
today's date? If the former, Date is not a good name since it can be
confused with the function for finding today's date. It is what is known as
a reserved word in Access. If the latter, I believe it needs to be
[Date()].

kate said:
Hello Thankyou for that but i need both rows to show

Arvin Meyer said:
You are trying to get both fields in 1 column. There are 2 possible
syntaxs:

IIf([Date1]=[Date],"stm","tmp")

Or:

IIf([Date1]=[Date],"stm",IIF([Date2]=[Date],"tmp",""))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

The first expression, doesn't look at [Date2] at all. The second
expression
will not even evaluate [Date2] if [Date1] is true.
I have a query which will give two results from running a switch i.e
iif
([Field date 1] = [date],"stm" iif [field date 2] = [date],"tmp"))

this will not give me both results what do i do ?????

Thankyou
 
B

BruceM

Sounds like you need the line feed and carriage return functions (or maybe
it's carriage return, then line feed - I can't recall, but they need to be
in the order given), which is what chr(13) and chr(10) represent. The idea
is that if both dates match, you will see:

ogd
stm

If either matches you will see ogd or stm, as the case may be. If neither
matches the field will be blank.

I have not tested this expression. Substitute your actual field names.
Watch for line wrapping. This should all be on one line.

NewField: IIf([ParamDate] = [DateOgd] And [ParamDate] = [DateStm], "ogd" &
chr(13) & chr(10) & "stm",IIf([ParamDate] = [DateOgd], "ogd",IIf([ParamDate]
= [DateStm], "stm","")))

kate said:
I am sorry I am not trying to confuse anyone.
I have Fields in a query ok one is called [date for ogd] another is called
[date for stm] and another called [date for tmp].I would like to run a
query
in a new field that says iif [a date i put in a parameter field] = [date
for
ogd], "ogd",iif [a date i put in a parameter field]= [date for stm],"stm")

this is an inputted date [a date i put in a parameter field]

If this date matches both criteria I want to see both but not like
"ogdstm"
i require it to give me to rows


I hope this makes sense
thankyou

BruceM said:
If you are talking about rows in the query's datasheet view you are
talking
about two separate records. On another point, is [Date] a field, or is
it
today's date? If the former, Date is not a good name since it can be
confused with the function for finding today's date. It is what is known
as
a reserved word in Access. If the latter, I believe it needs to be
[Date()].

kate said:
Hello Thankyou for that but i need both rows to show

:

You are trying to get both fields in 1 column. There are 2 possible
syntaxs:

IIf([Date1]=[Date],"stm","tmp")

Or:

IIf([Date1]=[Date],"stm",IIF([Date2]=[Date],"tmp",""))
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

The first expression, doesn't look at [Date2] at all. The second
expression
will not even evaluate [Date2] if [Date1] is true.
I have a query which will give two results from running a switch i.e
iif
([Field date 1] = [date],"stm" iif [field date 2] = [date],"tmp"))

this will not give me both results what do i do ?????

Thankyou
 
Top