HardCode calculated field in a query

G

Guest

I have a query which has a calculated field which is date difference of start
date and end date. No when i run the query the calculated field shows either
0, >0 or <0 values in the field. What i want is to somehow hardcode the
displayed values instead of 0, >0 or <0. Like if it is 0 or >0 i want to
display "yes" and if it is <0 i want to display "No". How can i do this.
 
G

Guest

But where do i write this code in the query?

Douglas J Steele said:
IIf([MyField] <= 0, "yes", "no")

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pitu said:
I have a query which has a calculated field which is date difference of start
date and end date. No when i run the query the calculated field shows either
0, >0 or <0 values in the field. What i want is to somehow hardcode the
displayed values instead of 0, >0 or <0. Like if it is 0 or >0 i want to
display "yes" and if it is <0 i want to display "No". How can i do this.
 
G

Guest

where do i write this code in the query?

Gina Whipp said:
You mean like.. YesNo: IIf([NameOfCalculatedField]<0, "No", "Yes")

Pitu said:
I have a query which has a calculated field which is date difference of
start
date and end date. No when i run the query the calculated field shows
either
0, >0 or <0 values in the field. What i want is to somehow hardcode the
displayed values instead of 0, >0 or <0. Like if it is 0 or >0 i want to
display "yes" and if it is <0 i want to display "No". How can i do this.
 
G

Gina Whipp

Open your query, go to the end and copy and paste the below on the Field:
line, then replace 'NameOfCalculatedField' with the name of the field. View
the query if all is well, close and save. If not, write back.


Pitu said:
where do i write this code in the query?

Gina Whipp said:
You mean like.. YesNo: IIf([NameOfCalculatedField]<0, "No", "Yes")

Pitu said:
I have a query which has a calculated field which is date difference of
start
date and end date. No when i run the query the calculated field shows
either
0, >0 or <0 values in the field. What i want is to somehow hardcode the
displayed values instead of 0, >0 or <0. Like if it is 0 or >0 i want
to
display "yes" and if it is <0 i want to display "No". How can i do
this.
 
G

Guest

Thanks Gina

Gina Whipp said:
Open your query, go to the end and copy and paste the below on the Field:
line, then replace 'NameOfCalculatedField' with the name of the field. View
the query if all is well, close and save. If not, write back.


Pitu said:
where do i write this code in the query?

Gina Whipp said:
You mean like.. YesNo: IIf([NameOfCalculatedField]<0, "No", "Yes")

I have a query which has a calculated field which is date difference of
start
date and end date. No when i run the query the calculated field shows
either
0, >0 or <0 values in the field. What i want is to somehow hardcode the
displayed values instead of 0, >0 or <0. Like if it is 0 or >0 i want
to
display "yes" and if it is <0 i want to display "No". How can i do
this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top