Hiding a line in a report based on a field

  • Thread starter Thread starter Sonia
  • Start date Start date
S

Sonia

Hi,



I've a field under Details which displays the results when '=Age > 18' but
the report is also showing lines of records when the same field contains Age
=< 18.

HOWTO hide unneeded lines in a report based on the results/content of a
field?

TIA

Sonia
 
Best way is to calculate the age in a query, then apply criteria. Since you
have provided so little information I will assume that your table has a
BirthDate field. Make a query based on that table, then add the following
to an empty column in the query design grid:

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

In the criteria row for that field, put: >18 to see everybody older than
18, or >=18 to see everybody 18 or older.

Base your report on the query. Bind a text box to the Age field.

A Google groups search turned up the code I provided. It was in a posting
several years ago by John Vinson. Google groups is a good first step in
figuring out a problem. I am familiar with DateDiff, but the calculation:
Age: DateDiff("yyyy",[BirthDate],Date()) shows everybody's age as one
greater than it is, since any fraction of a year is counted as a full year.
Subtracting one from that seems to work, except on a person's birthday.
John's solution will take care of all that.
 
Back
Top