Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 4th, 2005, 06:50 AM
Dizzy1 Dizzy1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 1 Dizzy1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 36 sec
Reputation Power: 0
Angry Age Category - referencing another field

i have a database set up with an age field in it which calculates the amount of days an item is in a certain place. This works fine. I now want to use the answers from this age field to calculate an age category, to say if the amount of days are less than or more than a week, (age less than or more than 7). however i have tried loads of different ways and cant seem to get this to work as it keeps looking for parameters. how do i get it to reference the age field?? and caterogise this please? its doing my head in!!!!

Reply With Quote
  #2  
Old August 4th, 2005, 12:45 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
You didn't specify how you wanted to view the results ie. form or query, so here are both

Query:

Assuming you are using the DateDiff function to get the number of days between two dates, (fields are named Date1 and Date2) then your first expression would look like this:

Days Age: DateDiff("d",[Date1],[Date2])

The second expression would look like this:

Category: IIf([Days Age]<7 Or [Days Age]>7,"Beyond Range","In Range")

Note however, that only those Days Age that = 7 will be In Range all other numbers will be Beyond Range

If you are viewing the results in a bound form, then place two unbound textboxes named Days Age and Category respectively on the form to perform the calculations. In the On Current Event of the form add the following code:

[Days Age] = DateDiff("d", [Date1], [Date2])
[Category] = IIf([Days Age] < 7 Or [Days Age] > 7, "Beyond Range", "In Range")

lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Age Category - referencing another field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT