|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!!!!
|
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Age Category - referencing another field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|