Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report - "New" tag for records less than 5 days old 1

Status
Not open for further replies.

kokua

Technical User
Jun 9, 2003
2
US
I am printing a daily report submitted online by our users and every record carries a date-time stamp. Is there a way to put a "New" tag for records that are less than 5 days old and that the tag will disappear if the record is older than 5 days?
 
Sure, use an if statement that compares the field's date value with now().

tell us more about how/where you would want
the flag, and we can get more specific.
it could be as simple as a label you set
visible to true or false based on that condition.

-g
 
Thanks for the reply. I am trying to put a tag in the details section displaying alongside each individual record. More than likely it's just a matter of coding an IF statement. How would I code a control statement so that

IF [date_stamp] is less than 5 days old,
show "new" on the record
ELSE
show ""

I know I can do this in a query to test the days difference

IF DateDiff("d", [Date_Stamp], Now()) > 5

However, not sure how to insert such condition in a report control text box.

Mahalo!
 
Well, you probably wouldn't put it in the control source...
like i originally suggested, how about making a lable
with the text "new" in the right spot, then click on
the background of the section it resides, choose
events, onformat event, code (rather than macro),
then place code something like this in the function
it builds:

if (IF DateDiff(&quot;d&quot;, <textbox holding date val>, Now()) > 5) then
<labelname>.visible = false
else
<labelname>.visible = true
end if

doublecheck datediff's definition in the help files
to make sure it's the same as the sql one you're
used to (probably is, but i'm not at my usual
computer right now to verify this myself)

-g
 
How about a text box with Source:

=iif(Now()-[Date_Stamp]>5,&quot;New&quot;,&quot;&quot;)
 
Oops, I mean:

=iif(Now()-[Date_Stamp]<5,&quot;New&quot;,&quot;&quot;)
 
not a bad idea! i guess you CAN do it in a controlsource!
have a star~

..still, i'd use datediff and not date-date.

-g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top