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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Count Years



 
 
Thread Tools Display Modes
  #1  
Old February 27th, 2010, 11:17 PM posted to microsoft.public.access.forms
Iram
external usenet poster
 
Posts: 122
Default Count Years

Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp

  #2  
Old February 27th, 2010, 11:42 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Count Years

On Sat, 27 Feb 2010 15:17:01 -0800, Iram
wrote:

Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp


A calculated field in your query such as

Years: Round(DateDiff("d", [Date Arrived], [Forms]!{YourFormName]![OnDate]) /
365.25, 1)

should work.
--

John W. Vinson [MVP]
  #3  
Old February 28th, 2010, 01:58 AM posted to microsoft.public.access.forms
Iram
external usenet poster
 
Posts: 122
Default Count Years

I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?



Thanks.
Iram/mcp

"John W. Vinson" wrote:

On Sat, 27 Feb 2010 15:17:01 -0800, Iram
wrote:

Hello,
I have a continuous form with the following fields, First Name, Last Name,
Date Arrived.

In the continuous form next to these fields I would like to add a field
called Years that calculates how many years since they have arrived for
example...

First Name Last Name Date Arrived Years
John Johnson 01/27/2008 2.1

How do I write the logic into the Years field?

I would need it exact with one digit after the decimal as shown above, but
not two digits after the decimal.

In a report I would need similar logic but I would need the logic to
determine how many years the person has been here based upon a date I put in
a form in a field called "OnDate". In other words how many years between the
date arrived and the date I put on a form.

Can you please help me with this?

Thanks.
Iram/mcp


A calculated field in your query such as

Years: Round(DateDiff("d", [Date Arrived], [Forms]!{YourFormName]![OnDate]) /
365.25, 1)

should work.
--

John W. Vinson [MVP]
.

  #4  
Old February 28th, 2010, 06:59 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Count Years

On Sat, 27 Feb 2010 17:58:01 -0800, Iram
wrote:

I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?


Open the query in design view.

Find a vacant Field cell in the top row.

Type the expression into that field cell; in this case just type or copy and
paste

Years: Round(DateDiff("d", [Date Arrived], [Forms]![YourFormName]![OnDate]) /
365.25, 1)

into that cell, all on one line, replacing "YourFormName" with the actual name
of the form that you are using.

--

John W. Vinson [MVP]
  #5  
Old March 1st, 2010, 05:23 AM posted to microsoft.public.access.forms
Iram
external usenet poster
 
Posts: 122
Default Count Years

Cool Thanks that worked John!

I have a calculated field in a different query that I need to fix, why
doesn' this work?

Years: Round(DateDiff("d",[FechaEntroObra],Date())/365.25,1)

I need a year count between the field "FechaEntroObra" and today's date.


Thanks.
Iram/mcp



"John W. Vinson" wrote:

On Sat, 27 Feb 2010 17:58:01 -0800, Iram
wrote:

I did a calculated field in a query a long time ago,
Can you refresh my memory on how to do it exactly?


Open the query in design view.

Find a vacant Field cell in the top row.

Type the expression into that field cell; in this case just type or copy and
paste

Years: Round(DateDiff("d", [Date Arrived], [Forms]![YourFormName]![OnDate]) /
365.25, 1)

into that cell, all on one line, replacing "YourFormName" with the actual name
of the form that you are using.

--

John W. Vinson [MVP]
.

  #6  
Old March 1st, 2010, 07:09 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Count Years

On Sun, 28 Feb 2010 21:23:01 -0800, Iram
wrote:

Cool Thanks that worked John!

I have a calculated field in a different query that I need to fix, why
doesn' this work?

Years: Round(DateDiff("d",[FechaEntroObra],Date())/365.25,1)

I need a year count between the field "FechaEntroObra" and today's date.


In what way does it "not work"? What happens if you build it up piecewise:
first DateDiff("d", [FechaEntroObra], Date()), then the division, then the
round? What's actually in the FechaEntroObra field - a date/time value as the
name suggests, or is it perhaps a date in a Text field?

--

John W. Vinson [MVP]
 




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 05:18 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.