Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-2008, 09:17 PM
=?Utf-8?B?Tm9uYQ==?=
 
Posts: n/a
Database determine adult or child

For a database report, I need to show whether individuals are children are
adults via a Yes/No field.

On the data entry form, I already have a field that calculates the age from
the dob.
This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())

However, when I have tried to use that same calculation in a query, it
doesn't work. So I went to your previous q/a and copied two formulas given
there, and neither of them worked in my query either.

Age:
Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))

Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
Format([DOB], "mmdd"), 1, 0)


If I use "Group By" in the query, it tells me that I have a syntax
error(comma) in the query expression.
If I use "Expression", it apparently doesn't recognize the DOB field. Even
tho the DOB is itself in the query and gives the birthdates correctly.

Everything else in the query works! What am I doing wrong?
I was planning to get the age in a query, then use the IIf command to
determine if the individual is over 18 and get a yes/no response for my
report.

Thanks for any help you can offer!
--
Nona
Reply With Quote
  #2 (permalink)  
Old 09-08-2008, 09:31 PM
=?Utf-8?B?V2F5bmUtSS1N?=
 
Posts: n/a
RE: Database determine adult or child

Add the table to name to the query formula like this

Age: DateDiff("yyyy",[TableName]![DOB],Date())

Its the same with the IIF

OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
18")

This assumes that DOB field contains a date ?




--
Wayne
Manchester, England.



"Nona" wrote:

> For a database report, I need to show whether individuals are children are
> adults via a Yes/No field.
>
> On the data entry form, I already have a field that calculates the age from
> the dob.
> This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
>
> However, when I have tried to use that same calculation in a query, it
> doesn't work. So I went to your previous q/a and copied two formulas given
> there, and neither of them worked in my query either.
>
> Age:
> Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
>
> Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> Format([DOB], "mmdd"), 1, 0)
>
>
> If I use "Group By" in the query, it tells me that I have a syntax
> error(comma) in the query expression.
> If I use "Expression", it apparently doesn't recognize the DOB field. Even
> tho the DOB is itself in the query and gives the birthdates correctly.
>
> Everything else in the query works! What am I doing wrong?
> I was planning to get the age in a query, then use the IIf command to
> determine if the individual is over 18 and get a yes/no response for my
> report.
>
> Thanks for any help you can offer!
> --
> Nona

Reply With Quote
  #3 (permalink)  
Old 09-08-2008, 11:02 PM
=?Utf-8?B?Tm9uYQ==?=
 
Posts: n/a
RE: Database determine adult or child

Thanks for your reply. I inserted the table name ([tblConsumers]!) exactly as
you suggested. Unfortunately (for me), this is not working either. I'm
getting the exact same error messages as before. I'm sure I'm doing something
wrong, but I have no idea what that could be! Should it be listed as an
Expression? I've tried both your formulas as Group By and as Expressions, but
that didn't help.

--
Nona


"Wayne-I-M" wrote:

> Add the table to name to the query formula like this
>
> Age: DateDiff("yyyy",[TableName]![DOB],Date())
>
> Its the same with the IIF
>
> OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> 18")
>
> This assumes that DOB field contains a date ?
>
>
>
>
> --
> Wayne
> Manchester, England.
>
>
>
> "Nona" wrote:
>
> > For a database report, I need to show whether individuals are children are
> > adults via a Yes/No field.
> >
> > On the data entry form, I already have a field that calculates the age from
> > the dob.
> > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> >
> > However, when I have tried to use that same calculation in a query, it
> > doesn't work. So I went to your previous q/a and copied two formulas given
> > there, and neither of them worked in my query either.
> >
> > Age:
> > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> >
> > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > Format([DOB], "mmdd"), 1, 0)
> >
> >
> > If I use "Group By" in the query, it tells me that I have a syntax
> > error(comma) in the query expression.
> > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > tho the DOB is itself in the query and gives the birthdates correctly.
> >
> > Everything else in the query works! What am I doing wrong?
> > I was planning to get the age in a query, then use the IIf command to
> > determine if the individual is over 18 and get a yes/no response for my
> > report.
> >
> > Thanks for any help you can offer!
> > --
> > Nona

Reply With Quote
  #4 (permalink)  
Old 09-08-2008, 11:18 PM
=?Utf-8?B?bWljaw==?=
 
Posts: n/a
RE: Database determine adult or child

I think you put the formula in the "field" row of a column.

Look for an empty column and you put the formula in the top row of that.

- This was my 1st ever answer to a question I REALLY hope it's right

Mick
Preston City, UK


"Nona" wrote:

> Thanks for your reply. I inserted the table name ([tblConsumers]!) exactly as
> you suggested. Unfortunately (for me), this is not working either. I'm
> getting the exact same error messages as before. I'm sure I'm doing something
> wrong, but I have no idea what that could be! Should it be listed as an
> Expression? I've tried both your formulas as Group By and as Expressions, but
> that didn't help.
>
> --
> Nona
>
>
> "Wayne-I-M" wrote:
>
> > Add the table to name to the query formula like this
> >
> > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> >
> > Its the same with the IIF
> >
> > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > 18")
> >
> > This assumes that DOB field contains a date ?
> >
> >
> >
> >
> > --
> > Wayne
> > Manchester, England.
> >
> >
> >
> > "Nona" wrote:
> >
> > > For a database report, I need to show whether individuals are children are
> > > adults via a Yes/No field.
> > >
> > > On the data entry form, I already have a field that calculates the age from
> > > the dob.
> > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > >
> > > However, when I have tried to use that same calculation in a query, it
> > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > there, and neither of them worked in my query either.
> > >
> > > Age:
> > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > >
> > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > Format([DOB], "mmdd"), 1, 0)
> > >
> > >
> > > If I use "Group By" in the query, it tells me that I have a syntax
> > > error(comma) in the query expression.
> > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > tho the DOB is itself in the query and gives the birthdates correctly.
> > >
> > > Everything else in the query works! What am I doing wrong?
> > > I was planning to get the age in a query, then use the IIf command to
> > > determine if the individual is over 18 and get a yes/no response for my
> > > report.
> > >
> > > Thanks for any help you can offer!
> > > --
> > > Nona

Reply With Quote
  #5 (permalink)  
Old 09-08-2008, 11:22 PM
=?Utf-8?B?V2F5bmUtSS1N?=
 
Posts: n/a
RE: Database determine adult or child

Turn off the grouping (its the sideways Z at the top of the screen)

Put the formula in a calculated column (the field row)

--
Wayne
Manchester, England.



"Nona" wrote:

> Thanks for your reply. I inserted the table name ([tblConsumers]!) exactly as
> you suggested. Unfortunately (for me), this is not working either. I'm
> getting the exact same error messages as before. I'm sure I'm doing something
> wrong, but I have no idea what that could be! Should it be listed as an
> Expression? I've tried both your formulas as Group By and as Expressions, but
> that didn't help.
>
> --
> Nona
>
>
> "Wayne-I-M" wrote:
>
> > Add the table to name to the query formula like this
> >
> > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> >
> > Its the same with the IIF
> >
> > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > 18")
> >
> > This assumes that DOB field contains a date ?
> >
> >
> >
> >
> > --
> > Wayne
> > Manchester, England.
> >
> >
> >
> > "Nona" wrote:
> >
> > > For a database report, I need to show whether individuals are children are
> > > adults via a Yes/No field.
> > >
> > > On the data entry form, I already have a field that calculates the age from
> > > the dob.
> > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > >
> > > However, when I have tried to use that same calculation in a query, it
> > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > there, and neither of them worked in my query either.
> > >
> > > Age:
> > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > >
> > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > Format([DOB], "mmdd"), 1, 0)
> > >
> > >
> > > If I use "Group By" in the query, it tells me that I have a syntax
> > > error(comma) in the query expression.
> > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > tho the DOB is itself in the query and gives the birthdates correctly.
> > >
> > > Everything else in the query works! What am I doing wrong?
> > > I was planning to get the age in a query, then use the IIf command to
> > > determine if the individual is over 18 and get a yes/no response for my
> > > report.
> > >
> > > Thanks for any help you can offer!
> > > --
> > > Nona

Reply With Quote
  #6 (permalink)  
Old 09-08-2008, 11:36 PM
=?Utf-8?B?Tm9uYQ==?=
 
Posts: n/a
RE: Database determine adult or child

Thanks, Mick and Wayne,

One of the things I really enjoy about working with Access is the problem
solving. I enjoy the challenges. But this one is getting to me. It seems so
simple, but is so frustrating!

I entered the formula, including the table name, in the field row, with no
grouping, but I get the same syntax error message.

Any other suggestions?????






--
Nona


"Wayne-I-M" wrote:

> Turn off the grouping (its the sideways Z at the top of the screen)
>
> Put the formula in a calculated column (the field row)
>
> --
> Wayne
> Manchester, England.
>
>
>
> "Nona" wrote:
>
> > Thanks for your reply. I inserted the table name ([tblConsumers]!) exactly as
> > you suggested. Unfortunately (for me), this is not working either. I'm
> > getting the exact same error messages as before. I'm sure I'm doing something
> > wrong, but I have no idea what that could be! Should it be listed as an
> > Expression? I've tried both your formulas as Group By and as Expressions, but
> > that didn't help.
> >
> > --
> > Nona
> >
> >
> > "Wayne-I-M" wrote:
> >
> > > Add the table to name to the query formula like this
> > >
> > > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> > >
> > > Its the same with the IIF
> > >
> > > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > > 18")
> > >
> > > This assumes that DOB field contains a date ?
> > >
> > >
> > >
> > >
> > > --
> > > Wayne
> > > Manchester, England.
> > >
> > >
> > >
> > > "Nona" wrote:
> > >
> > > > For a database report, I need to show whether individuals are children are
> > > > adults via a Yes/No field.
> > > >
> > > > On the data entry form, I already have a field that calculates the age from
> > > > the dob.
> > > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > > >
> > > > However, when I have tried to use that same calculation in a query, it
> > > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > > there, and neither of them worked in my query either.
> > > >
> > > > Age:
> > > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > > >
> > > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > > Format([DOB], "mmdd"), 1, 0)
> > > >
> > > >
> > > > If I use "Group By" in the query, it tells me that I have a syntax
> > > > error(comma) in the query expression.
> > > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > > tho the DOB is itself in the query and gives the birthdates correctly.
> > > >
> > > > Everything else in the query works! What am I doing wrong?
> > > > I was planning to get the age in a query, then use the IIf command to
> > > > determine if the individual is over 18 and get a yes/no response for my
> > > > report.
> > > >
> > > > Thanks for any help you can offer!
> > > > --
> > > > Nona

Reply With Quote
  #7 (permalink)  
Old 09-08-2008, 11:47 PM
=?Utf-8?B?V2F5bmUtSS1N?=
 
Posts: n/a
RE: Database determine adult or child

Can you see the table in the top section of the query in design view
Is the field DOB in the table a date field
Does it contain a date
Have you changed the TabeName in the formula to the real name of the table
Is your query a simple select query

If all these are yes can you post the sql of the query -
go to design view
then select View
then Select SQL then copy and post the sql so we can look at it


--
Wayne
Manchester, England.



"Nona" wrote:

> Thanks, Mick and Wayne,
>
> One of the things I really enjoy about working with Access is the problem
> solving. I enjoy the challenges. But this one is getting to me. It seems so
> simple, but is so frustrating!
>
> I entered the formula, including the table name, in the field row, with no
> grouping, but I get the same syntax error message.
>
> Any other suggestions?????
>
>
>
>
>
>
> --
> Nona
>
>
> "Wayne-I-M" wrote:
>
> > Turn off the grouping (its the sideways Z at the top of the screen)
> >
> > Put the formula in a calculated column (the field row)
> >
> > --
> > Wayne
> > Manchester, England.
> >
> >
> >
> > "Nona" wrote:
> >
> > > Thanks for your reply. I inserted the table name ([tblConsumers]!) exactly as
> > > you suggested. Unfortunately (for me), this is not working either. I'm
> > > getting the exact same error messages as before. I'm sure I'm doing something
> > > wrong, but I have no idea what that could be! Should it be listed as an
> > > Expression? I've tried both your formulas as Group By and as Expressions, but
> > > that didn't help.
> > >
> > > --
> > > Nona
> > >
> > >
> > > "Wayne-I-M" wrote:
> > >
> > > > Add the table to name to the query formula like this
> > > >
> > > > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> > > >
> > > > Its the same with the IIF
> > > >
> > > > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > > > 18")
> > > >
> > > > This assumes that DOB field contains a date ?
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Wayne
> > > > Manchester, England.
> > > >
> > > >
> > > >
> > > > "Nona" wrote:
> > > >
> > > > > For a database report, I need to show whether individuals are children are
> > > > > adults via a Yes/No field.
> > > > >
> > > > > On the data entry form, I already have a field that calculates the age from
> > > > > the dob.
> > > > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > > > >
> > > > > However, when I have tried to use that same calculation in a query, it
> > > > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > > > there, and neither of them worked in my query either.
> > > > >
> > > > > Age:
> > > > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > > > >
> > > > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > > > Format([DOB], "mmdd"), 1, 0)
> > > > >
> > > > >
> > > > > If I use "Group By" in the query, it tells me that I have a syntax
> > > > > error(comma) in the query expression.
> > > > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > > > tho the DOB is itself in the query and gives the birthdates correctly.
> > > > >
> > > > > Everything else in the query works! What am I doing wrong?
> > > > > I was planning to get the age in a query, then use the IIf command to
> > > > > determine if the individual is over 18 and get a yes/no response for my
> > > > > report.
> > > > >
> > > > > Thanks for any help you can offer!
> > > > > --
> > > > > Nona

Reply With Quote
  #8 (permalink)  
Old 09-09-2008, 12:00 AM
=?Utf-8?B?Tm9uYQ==?=
 
Posts: n/a
RE: Database determine adult or child

The answer to all of your questions is yes. The DOB is a date field, and the
query runs correctly with correct output in all fields until I add these
formulas to get the age.


SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
tblConsumers.LMEID, tblConsumers.D0B, tblConsumers.TLFN, tblConsumers.TLLN,
tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
tblConsumers.SSN, IIf(DateDiff("yyyy",[tblConsumers]![DOB],Date())>18,"Over
18","Under 18") AS OverUnder
FROM tblConsumers
WHERE (((tblConsumers.ClientStatus)="Active"));


I really, really, really appreciate your time and patience.

--
Nona


"Wayne-I-M" wrote:

> Add the table to name to the query formula like this
>
> Age: DateDiff("yyyy",[TableName]![DOB],Date())
>
> Its the same with the IIF
>
> OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> 18")
>
> This assumes that DOB field contains a date ?
>
>
>
>
> --
> Wayne
> Manchester, England.
>
>
>
> "Nona" wrote:
>
> > For a database report, I need to show whether individuals are children are
> > adults via a Yes/No field.
> >
> > On the data entry form, I already have a field that calculates the age from
> > the dob.
> > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> >
> > However, when I have tried to use that same calculation in a query, it
> > doesn't work. So I went to your previous q/a and copied two formulas given
> > there, and neither of them worked in my query either.
> >
> > Age:
> > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> >
> > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > Format([DOB], "mmdd"), 1, 0)
> >
> >
> > If I use "Group By" in the query, it tells me that I have a syntax
> > error(comma) in the query expression.
> > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > tho the DOB is itself in the query and gives the birthdates correctly.
> >
> > Everything else in the query works! What am I doing wrong?
> > I was planning to get the age in a query, then use the IIf command to
> > determine if the individual is over 18 and get a yes/no response for my
> > report.
> >
> > Thanks for any help you can offer!
> > --
> > Nona

Reply With Quote
  #9 (permalink)  
Old 09-09-2008, 12:26 AM
=?Utf-8?B?QmVldGxl?=
 
Posts: n/a
RE: Database determine adult or child

I just set up a table with the same field names as yours. The following query
works exactly as expected;

SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
tblConsumers.LMEID, tblConsumers.DOB, tblConsumers.TLFN, tblConsumers.TLLN,
tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
tblConsumers.SSN,
IIf(DateDiff("yyyy",[DOB],Date())-IIf(Format(Date(),"mmdd")<Format([DOB],"mmdd"),1,0)>18,"Over 18","Under 18") AS OverUnder
FROM tblConsumers
WHERE (((tblConsumers.ClientStatus)="Active"));

--
_________

Sean Bailey


"Nona" wrote:

> The answer to all of your questions is yes. The DOB is a date field, and the
> query runs correctly with correct output in all fields until I add these
> formulas to get the age.
>
>
> SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
> tblConsumers.LMEID, tblConsumers.D0B, tblConsumers.TLFN, tblConsumers.TLLN,
> tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
> tblConsumers.SSN, IIf(DateDiff("yyyy",[tblConsumers]![DOB],Date())>18,"Over
> 18","Under 18") AS OverUnder
> FROM tblConsumers
> WHERE (((tblConsumers.ClientStatus)="Active"));
>
>
> I really, really, really appreciate your time and patience.
>
> --
> Nona
>
>
> "Wayne-I-M" wrote:
>
> > Add the table to name to the query formula like this
> >
> > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> >
> > Its the same with the IIF
> >
> > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > 18")
> >
> > This assumes that DOB field contains a date ?
> >
> >
> >
> >
> > --
> > Wayne
> > Manchester, England.
> >
> >
> >
> > "Nona" wrote:
> >
> > > For a database report, I need to show whether individuals are children are
> > > adults via a Yes/No field.
> > >
> > > On the data entry form, I already have a field that calculates the age from
> > > the dob.
> > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > >
> > > However, when I have tried to use that same calculation in a query, it
> > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > there, and neither of them worked in my query either.
> > >
> > > Age:
> > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > >
> > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > Format([DOB], "mmdd"), 1, 0)
> > >
> > >
> > > If I use "Group By" in the query, it tells me that I have a syntax
> > > error(comma) in the query expression.
> > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > tho the DOB is itself in the query and gives the birthdates correctly.
> > >
> > > Everything else in the query works! What am I doing wrong?
> > > I was planning to get the age in a query, then use the IIf command to
> > > determine if the individual is over 18 and get a yes/no response for my
> > > report.
> > >
> > > Thanks for any help you can offer!
> > > --
> > > Nona

Reply With Quote
  #10 (permalink)  
Old 09-09-2008, 12:55 AM
=?Utf-8?B?Tm9uYQ==?=
 
Posts: n/a
RE: Database determine adult or child

Congratulations, Beetle. I'm glad it worked for you. I just wish you could
tell me why it won't run for me. I copied your statement and pasted it onto
my query. It still didn't work. Won't recognize DOB in the calculated fields.
(It does recognize and gives the correct dob without the calculations.)

It does give output for the Over/Under field, but it's wrong. Says all 290
consumers are under 18, which is not the case.

Here is the SQL stmt I just used...
SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
tblConsumers.LMEID, tblConsumers.D0B, tblConsumers.TLFN, tblConsumers.TLLN,
tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
tblConsumers.SSN,
IIf(DateDiff("yyyy",[DOB],Date())-IIf(Format(Date(),"mmdd")<Format([DOB],"mmdd"),1,0)>18,"Over 18","Under 18") AS OverUnder
FROM tblConsumers
WHERE (((tblConsumers.ClientStatus)="Active"));

I can't believe this is happening...! I appreciate your efforts.








--
Nona


"Beetle" wrote:

> I just set up a table with the same field names as yours. The following query
> works exactly as expected;
>
> SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
> tblConsumers.LMEID, tblConsumers.DOB, tblConsumers.TLFN, tblConsumers.TLLN,
> tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
> tblConsumers.SSN,
> IIf(DateDiff("yyyy",[DOB],Date())-IIf(Format(Date(),"mmdd")<Format([DOB],"mmdd"),1,0)>18,"Over 18","Under 18") AS OverUnder
> FROM tblConsumers
> WHERE (((tblConsumers.ClientStatus)="Active"));
>
> --
> _________
>
> Sean Bailey
>
>
> "Nona" wrote:
>
> > The answer to all of your questions is yes. The DOB is a date field, and the
> > query runs correctly with correct output in all fields until I add these
> > formulas to get the age.
> >
> >
> > SELECT tblConsumers.CLN, tblConsumers.CFN, tblConsumers.ClientStatus,
> > tblConsumers.LMEID, tblConsumers.D0B, tblConsumers.TLFN, tblConsumers.TLLN,
> > tblConsumers.CtyofRes, tblConsumers.DOA, tblConsumers.Source,
> > tblConsumers.SSN, IIf(DateDiff("yyyy",[tblConsumers]![DOB],Date())>18,"Over
> > 18","Under 18") AS OverUnder
> > FROM tblConsumers
> > WHERE (((tblConsumers.ClientStatus)="Active"));
> >
> >
> > I really, really, really appreciate your time and patience.
> >
> > --
> > Nona
> >
> >
> > "Wayne-I-M" wrote:
> >
> > > Add the table to name to the query formula like this
> > >
> > > Age: DateDiff("yyyy",[TableName]![DOB],Date())
> > >
> > > Its the same with the IIF
> > >
> > > OverUnder: IIf(DateDiff("yyyy",[TableName]![DOB],Date())>18,"Over 18","Under
> > > 18")
> > >
> > > This assumes that DOB field contains a date ?
> > >
> > >
> > >
> > >
> > > --
> > > Wayne
> > > Manchester, England.
> > >
> > >
> > >
> > > "Nona" wrote:
> > >
> > > > For a database report, I need to show whether individuals are children are
> > > > adults via a Yes/No field.
> > > >
> > > > On the data entry form, I already have a field that calculates the age from
> > > > the dob.
> > > > This is the formula that works perfectly there: =DateDiff("yyyy",[DOB],Date())
> > > >
> > > > However, when I have tried to use that same calculation in a query, it
> > > > doesn't work. So I went to your previous q/a and copied two formulas given
> > > > there, and neither of them worked in my query either.
> > > >
> > > > Age:
> > > > Abs(DateDiff("yyyy",[DOB],Date())+(Format(Date(),"mmdd")<Format([DOB],"mmdd")))
> > > >
> > > > Age: DateDiff("yyyy", [DOB], Date()) - IIf(Format(Date(), "mmdd") <
> > > > Format([DOB], "mmdd"), 1, 0)
> > > >
> > > >
> > > > If I use "Group By" in the query, it tells me that I have a syntax
> > > > error(comma) in the query expression.
> > > > If I use "Expression", it apparently doesn't recognize the DOB field. Even
> > > > tho the DOB is itself in the query and gives the birthdates correctly.
> > > >
> > > > Everything else in the query works! What am I doing wrong?
> > > > I was planning to get the age in a query, then use the IIf command to
> > > > determine if the individual is over 18 and get a yes/no response for my
> > > > report.
> > > >
> > > > Thanks for any help you can offer!
> > > > --
> > > > Nona

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:16 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Loans | Problem Mortgage | Debt Consolidation | Myspace Proxy | Credit Card



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114